Exceptions in delegated c# functions

Mar 23, 2010 at 2:01 PM

When i pass delegate to Jint as function and exception occurs in that passed function, why it can't be cought by try\catch inside script? since its purely bussiness layer exception and could be handled by script. Or just how can i declare or use existing exception that can be caught in script and thrown from c# delegate?

Dec 29, 2010 at 6:58 AM

I've the same problem.

Jan 3, 2011 at 2:34 PM

Make sure the object you are 'throw'ing from the delegate inherits from Jint.Native.JsObject. If it does, a javascript catch statement can catch it. If it doesn't, then the catch will not work.



Jan 4, 2011 at 7:28 AM

Thank you for the answer. I throw the exception as follows and it works fine:

throw new JsException(new JsObject("..."));