So, one of the disadvantages of JScripts is the lack of visibility when it comes to exceptions – it can make troubleshooting frustratingly difficult. It is especially challenging when you are so used to the richness of the .Net exceptions.
I was recently working on a project where I got the wonderful Examine the InnerException for details, the only problem being that there is no InnerException property or field on the JScript exception.
If we do a GetType() on our exception object we see that it is an ErrorObject class
and not inherited from System.Exception.
After some investigation, I came across this post:
which nicely explains what happens and how to extract the .Net exception to get more detail.
In a nutshell, we test to ensure that our exception object is an ErrorObject using the instanceof command and then we use the static operator Explicit from the ErrorObject to convert it to an Exception.