sciter-sdk/rust-sciter

can't throw exception from Rust

gaoqiangz opened this issue · 4 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).