Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Raise a custom exception

$
0
0
Thanks for your answer!

As I see, I cannot
  • identify in the host application a JavaScript defined exception, like
function myException(message, 
{
this.name = 'myException';
this.message = message + ' ' + id;
this.id = id;
};
                          
myException.prototype = new Error();
myException.constructor = myException;
                            
throw new myException('this is a message', 42);
I only get the ScriptEngineException with the message as text. And
  • identify within my JavaScript code the type of the CLR exception, like
try {
   throwBadArg('one', 'two');
} 
catch (ex)
{
   if (ex instanceof ArgumentException)
   {
      // ...
   }
   else
   {
      // ...
   }
}
(I added the type to the engine before executing code).

Is that right? I only want to be sure that I haven't overlooked something.

Best regards,
Torsten

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>