1

Closed

Exception error description return nothing

description

When an exception is caught in javascript in the code below, the error message can be retrieved through the local variable in step event handler. But err.description return nothing.
                        try
                        {
                            //some code here throw exception
                        }
                        catch(err)
                        {
                            var errMessage = err.description;
                            alert(errMessage);
                        }
Closed Oct 3, 2014 at 5:43 PM by sebastienros
Jint has been rewritten and this issue should be fixed in the new version. Please check it on https://github.com/sebastienros/jint or on using the nuget package here: https://www.nuget.org/packages/Jint/

comments

cin wrote Aug 1, 2011 at 3:43 PM

err.description isn't defined in the ecma standard, use err.message instead

zhihongwang wrote Aug 1, 2011 at 8:50 PM

Thank you.
But I run into another problem. When .Net code starts an JintEngine to run javascript code which throw an exception as listed below, the .Net code catches a JintException. JintException.Message property just contains the original line of javascript code which throw the exception. It seems JintException.InnerException does not contain the original exception message either. How can the .net code get the original error message contained in errMessage variable in javascript code shown below?

try
{
//some code here throw exception
}
catch(err)
{
var errMessage = err.description;
throw errMessage;
}

cin wrote Aug 1, 2011 at 9:36 PM

Actually this may be a bug, need to think how to handle such cases, try to throw an error object rather than a string object. Currently expects either a js error object or a Clr exception object.