Hello, Torsten!
You can easily expose a function that throws a host exception. For example:
Keep in mind that exceptions thrown in this manner are likely to be wrapped by
On the other hand, if you need to catch and examine exceptions in JavaScript code, we recommend that you use JavaScript exceptions. Being normal JavaScript objects, they offer nearly infinite flexibility. That said, it is possible to catch and examine host exceptions in script code. See this thread for more information.
Good luck!
You can easily expose a function that throws a host exception. For example:
engine.Script.throwBadArg = new Action<string, string>((message, paramName) => { thrownew ArgumentException(message, paramName); });
ScriptEngineException
by the time they reach the host, so you'll have to use InnerException
or GetBaseException()
to examine them.On the other hand, if you need to catch and examine exceptions in JavaScript code, we recommend that you use JavaScript exceptions. Being normal JavaScript objects, they offer nearly infinite flexibility. That said, it is possible to catch and examine host exceptions in script code. See this thread for more information.
Good luck!