sciter-sdk / rust-sciter

Rust bindings for Sciter

Home Page:https://sciter.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't throw exception from Rust

gaoqiangz opened this issue · comments

rust:

impl Frame {
    fn throw(&self, ex: String) -> Result<(),String> {
        Err(ex)
    }
}
impl EventHandler for Frame {
    displatch_script_call! {
        fn throw(Value);
    }
}

js:

try {
    Window.this.xcall("throw","exception");
} catch(ex) {
    console.log(ex);
}

Let me check as well. It used to work for TIS.

Isn't ex supposed to be of type Value rather than String?

I confirm, it doesn't work in JS.

      try {
        stdout.println("call", view.throw());
      }
      catch(e) {
        stdout.println("exception", e);
      }
      try {
        console.log("call", Window.this.xcall("throw"));
      } catch(e) {
        console.log("exception", e);
      }

It prints "exception" in TIS but "call" in JS.

@c-smile Andrew, we initialize an exception here similar to value::make_error by calling ValueStringDataSet with UT_STRING_ERROR. It used to work in TIScript but doesn't work in JS (and seems has never been working judging by to a quick pick of several JS versions).