@@ -887,43 +887,47 @@ private static JsRuntimeException ConvertJsExceptionToJsRuntimeException(
887887 {
888888 category = "Script error" ;
889889 JsValue metadataValue = jsScriptException . Metadata ;
890- JsValue errorValue = metadataValue . GetProperty ( "exception" ) ;
891890
892- JsPropertyId stackPropertyId = JsPropertyId . FromString ( "stack" ) ;
893- if ( errorValue . HasProperty ( stackPropertyId ) )
891+ if ( metadataValue . IsValid )
894892 {
895- JsValue stackPropertyValue = errorValue . GetProperty ( stackPropertyId ) ;
896- message = stackPropertyValue . ConvertToString ( ) . ToString ( ) ;
897- }
898- else
899- {
900- JsValue messagePropertyValue = errorValue . GetProperty ( "message" ) ;
901- string scriptMessage = messagePropertyValue . ConvertToString ( ) . ToString ( ) ;
902- if ( ! string . IsNullOrWhiteSpace ( scriptMessage ) )
893+ JsValue errorValue = metadataValue . GetProperty ( "exception" ) ;
894+
895+ JsPropertyId stackPropertyId = JsPropertyId . FromString ( "stack" ) ;
896+ if ( errorValue . HasProperty ( stackPropertyId ) )
903897 {
904- message = string . Format ( "{0}: {1}" , message . TrimEnd ( '.' ) , scriptMessage ) ;
898+ JsValue stackPropertyValue = errorValue . GetProperty ( stackPropertyId ) ;
899+ message = stackPropertyValue . ConvertToString ( ) . ToString ( ) ;
900+ }
901+ else
902+ {
903+ JsValue messagePropertyValue = errorValue . GetProperty ( "message" ) ;
904+ string scriptMessage = messagePropertyValue . ConvertToString ( ) . ToString ( ) ;
905+ if ( ! string . IsNullOrWhiteSpace ( scriptMessage ) )
906+ {
907+ message = string . Format ( "{0}: {1}" , message . TrimEnd ( '.' ) , scriptMessage ) ;
908+ }
905909 }
906- }
907910
908- JsPropertyId linePropertyId = JsPropertyId . FromString ( "line" ) ;
909- if ( metadataValue . HasProperty ( linePropertyId ) )
910- {
911- JsValue linePropertyValue = metadataValue . GetProperty ( linePropertyId ) ;
912- lineNumber = linePropertyValue . ConvertToNumber ( ) . ToInt32 ( ) + 1 ;
913- }
911+ JsPropertyId linePropertyId = JsPropertyId . FromString ( "line" ) ;
912+ if ( metadataValue . HasProperty ( linePropertyId ) )
913+ {
914+ JsValue linePropertyValue = metadataValue . GetProperty ( linePropertyId ) ;
915+ lineNumber = linePropertyValue . ConvertToNumber ( ) . ToInt32 ( ) + 1 ;
916+ }
914917
915- JsPropertyId columnPropertyId = JsPropertyId . FromString ( "column" ) ;
916- if ( metadataValue . HasProperty ( columnPropertyId ) )
917- {
918- JsValue columnPropertyValue = metadataValue . GetProperty ( columnPropertyId ) ;
919- columnNumber = columnPropertyValue . ConvertToNumber ( ) . ToInt32 ( ) + 1 ;
920- }
918+ JsPropertyId columnPropertyId = JsPropertyId . FromString ( "column" ) ;
919+ if ( metadataValue . HasProperty ( columnPropertyId ) )
920+ {
921+ JsValue columnPropertyValue = metadataValue . GetProperty ( columnPropertyId ) ;
922+ columnNumber = columnPropertyValue . ConvertToNumber ( ) . ToInt32 ( ) + 1 ;
923+ }
921924
922- JsPropertyId sourcePropertyId = JsPropertyId . FromString ( "source" ) ;
923- if ( metadataValue . HasProperty ( sourcePropertyId ) )
924- {
925- JsValue sourcePropertyValue = metadataValue . GetProperty ( sourcePropertyId ) ;
926- sourceFragment = sourcePropertyValue . ConvertToString ( ) . ToString ( ) ;
925+ JsPropertyId sourcePropertyId = JsPropertyId . FromString ( "source" ) ;
926+ if ( metadataValue . HasProperty ( sourcePropertyId ) )
927+ {
928+ JsValue sourcePropertyValue = metadataValue . GetProperty ( sourcePropertyId ) ;
929+ sourceFragment = sourcePropertyValue . ConvertToString ( ) . ToString ( ) ;
930+ }
927931 }
928932 }
929933 else if ( jsException is JsUsageException )
@@ -939,7 +943,7 @@ private static JsRuntimeException ConvertJsExceptionToJsRuntimeException(
939943 category = "Fatal error" ;
940944 }
941945
942- var jsEngineException = new JsRuntimeException ( message , EngineName , EngineVersion )
946+ var jsEngineException = new JsRuntimeException ( message , EngineName , EngineVersion , jsException )
943947 {
944948 ErrorCode = ( ( uint ) jsException . ErrorCode ) . ToString ( CultureInfo . InvariantCulture ) ,
945949 Category = category ,
0 commit comments