@@ -8,114 +8,114 @@ internal static class JsErrorHelpers
88 /// <summary>
99 /// Throws if a native method returns an error code
1010 /// </summary>
11- /// <param name="error ">The error</param>
12- public static void ThrowIfError ( JsErrorCode error )
11+ /// <param name="errorCode ">The error code </param>
12+ public static void ThrowIfError ( JsErrorCode errorCode )
1313 {
14- if ( error != JsErrorCode . NoError )
14+ if ( errorCode != JsErrorCode . NoError )
1515 {
16- switch ( error )
16+ switch ( errorCode )
1717 {
1818 #region Usage
1919
2020 case JsErrorCode . InvalidArgument :
21- throw new JsUsageException ( error , "Invalid argument." ) ;
21+ throw new JsUsageException ( errorCode , "Invalid argument." ) ;
2222
2323 case JsErrorCode . NullArgument :
24- throw new JsUsageException ( error , "Null argument." ) ;
24+ throw new JsUsageException ( errorCode , "Null argument." ) ;
2525
2626 case JsErrorCode . NoCurrentContext :
27- throw new JsUsageException ( error , "No current context." ) ;
27+ throw new JsUsageException ( errorCode , "No current context." ) ;
2828
2929 case JsErrorCode . InExceptionState :
30- throw new JsUsageException ( error , "Runtime is in exception state." ) ;
30+ throw new JsUsageException ( errorCode , "Runtime is in exception state." ) ;
3131
3232 case JsErrorCode . NotImplemented :
33- throw new JsUsageException ( error , "Method is not implemented." ) ;
33+ throw new JsUsageException ( errorCode , "Method is not implemented." ) ;
3434
3535 case JsErrorCode . WrongThread :
36- throw new JsUsageException ( error , "Runtime is active on another thread." ) ;
36+ throw new JsUsageException ( errorCode , "Runtime is active on another thread." ) ;
3737
3838 case JsErrorCode . RuntimeInUse :
39- throw new JsUsageException ( error , "Runtime is in use." ) ;
39+ throw new JsUsageException ( errorCode , "Runtime is in use." ) ;
4040
4141 case JsErrorCode . BadSerializedScript :
42- throw new JsUsageException ( error , "Bad serialized script." ) ;
42+ throw new JsUsageException ( errorCode , "Bad serialized script." ) ;
4343
4444 case JsErrorCode . InDisabledState :
45- throw new JsUsageException ( error , "Runtime is disabled." ) ;
45+ throw new JsUsageException ( errorCode , "Runtime is disabled." ) ;
4646
4747 case JsErrorCode . CannotDisableExecution :
48- throw new JsUsageException ( error , "Cannot disable execution." ) ;
48+ throw new JsUsageException ( errorCode , "Cannot disable execution." ) ;
4949
5050 case JsErrorCode . HeapEnumInProgress :
51- throw new JsUsageException ( error , "Heap enumeration is in progress." ) ;
51+ throw new JsUsageException ( errorCode , "Heap enumeration is in progress." ) ;
5252
5353 case JsErrorCode . ArgumentNotObject :
54- throw new JsUsageException ( error , "Argument is not an object." ) ;
54+ throw new JsUsageException ( errorCode , "Argument is not an object." ) ;
5555
5656 case JsErrorCode . InProfileCallback :
57- throw new JsUsageException ( error , "In a profile callback." ) ;
57+ throw new JsUsageException ( errorCode , "In a profile callback." ) ;
5858
5959 case JsErrorCode . InThreadServiceCallback :
60- throw new JsUsageException ( error , "In a thread service callback." ) ;
60+ throw new JsUsageException ( errorCode , "In a thread service callback." ) ;
6161
6262 case JsErrorCode . CannotSerializeDebugScript :
63- throw new JsUsageException ( error , "Cannot serialize a debug script." ) ;
63+ throw new JsUsageException ( errorCode , "Cannot serialize a debug script." ) ;
6464
6565 case JsErrorCode . AlreadyDebuggingContext :
66- throw new JsUsageException ( error , "Context is already in debug mode." ) ;
66+ throw new JsUsageException ( errorCode , "Context is already in debug mode." ) ;
6767
6868 case JsErrorCode . AlreadyProfilingContext :
69- throw new JsUsageException ( error , "Already profiling this context." ) ;
69+ throw new JsUsageException ( errorCode , "Already profiling this context." ) ;
7070
7171 case JsErrorCode . IdleNotEnabled :
72- throw new JsUsageException ( error , "Idle is not enabled." ) ;
72+ throw new JsUsageException ( errorCode , "Idle is not enabled." ) ;
7373
7474 case JsErrorCode . CannotSetProjectionEnqueueCallback :
75- throw new JsUsageException ( error , "Cannot set projection enqueue callback." ) ;
75+ throw new JsUsageException ( errorCode , "Cannot set projection enqueue callback." ) ;
7676
7777 case JsErrorCode . CannotStartProjection :
78- throw new JsUsageException ( error , "Cannot start projection." ) ;
78+ throw new JsUsageException ( errorCode , "Cannot start projection." ) ;
7979
8080 case JsErrorCode . InObjectBeforeCollectCallback :
81- throw new JsUsageException ( error , "In object before collect callback." ) ;
81+ throw new JsUsageException ( errorCode , "In object before collect callback." ) ;
8282
8383 case JsErrorCode . ObjectNotInspectable :
84- throw new JsUsageException ( error , "Object not inspectable." ) ;
84+ throw new JsUsageException ( errorCode , "Object not inspectable." ) ;
8585
8686 case JsErrorCode . PropertyNotSymbol :
87- throw new JsUsageException ( error , "Property not symbol." ) ;
87+ throw new JsUsageException ( errorCode , "Property not symbol." ) ;
8888
8989 case JsErrorCode . PropertyNotString :
90- throw new JsUsageException ( error , "Property not string." ) ;
90+ throw new JsUsageException ( errorCode , "Property not string." ) ;
9191
9292 case JsErrorCode . InvalidContext :
93- throw new JsUsageException ( error , "Invalid context." ) ;
93+ throw new JsUsageException ( errorCode , "Invalid context." ) ;
9494
9595 case JsErrorCode . InvalidModuleHostInfoKind :
96- throw new JsUsageException ( error , "Invalid module host info kind." ) ;
96+ throw new JsUsageException ( errorCode , "Invalid module host info kind." ) ;
9797
9898 case JsErrorCode . ModuleParsed :
99- throw new JsUsageException ( error , "Module parsed." ) ;
99+ throw new JsUsageException ( errorCode , "Module parsed." ) ;
100100
101101 case JsErrorCode . NoWeakRefRequired :
102- throw new JsUsageException ( error , "No weak reference is required, the value will never be collected." ) ;
102+ throw new JsUsageException ( errorCode , "No weak reference is required, the value will never be collected." ) ;
103103
104104 case JsErrorCode . PromisePending :
105- throw new JsUsageException ( error , "The `Promise` object is still in the pending state." ) ;
105+ throw new JsUsageException ( errorCode , "The `Promise` object is still in the pending state." ) ;
106106
107107 case JsErrorCode . ModuleNotEvaluated :
108- throw new JsUsageException ( error , "Module was not yet evaluated when `JsGetModuleNamespace` was called." ) ;
108+ throw new JsUsageException ( errorCode , "Module was not yet evaluated when `JsGetModuleNamespace` was called." ) ;
109109
110110 #endregion
111111
112112 #region Engine
113113
114114 case JsErrorCode . OutOfMemory :
115- throw new JsEngineException ( error , "Out of memory." ) ;
115+ throw new JsEngineException ( errorCode , "Out of memory." ) ;
116116
117117 case JsErrorCode . BadFPUState :
118- throw new JsEngineException ( error , "Bad the Floating Point Unit state." ) ;
118+ throw new JsEngineException ( errorCode , "Bad the Floating Point Unit state." ) ;
119119
120120 #endregion
121121
@@ -125,39 +125,39 @@ public static void ThrowIfError(JsErrorCode error)
125125 case JsErrorCode . ScriptCompile :
126126 {
127127 JsValue errorMetadata ;
128- JsErrorCode innerError = NativeMethods . JsGetAndClearExceptionWithMetadata ( out errorMetadata ) ;
128+ JsErrorCode innerErrorCode = NativeMethods . JsGetAndClearExceptionWithMetadata ( out errorMetadata ) ;
129129
130- if ( innerError != JsErrorCode . NoError )
130+ if ( innerErrorCode != JsErrorCode . NoError )
131131 {
132- throw new JsFatalException ( innerError ) ;
132+ throw new JsFatalException ( innerErrorCode ) ;
133133 }
134134
135- string message = error == JsErrorCode . ScriptCompile ?
135+ string message = errorCode == JsErrorCode . ScriptCompile ?
136136 "Compile error." : "Script threw an exception." ;
137137
138- throw new JsScriptException ( error , errorMetadata , message ) ;
138+ throw new JsScriptException ( errorCode , errorMetadata , message ) ;
139139 }
140140
141141 case JsErrorCode . ScriptTerminated :
142- throw new JsScriptException ( error , JsValue . Invalid , "Script was terminated." ) ;
142+ throw new JsScriptException ( errorCode , JsValue . Invalid , "Script was terminated." ) ;
143143
144144 case JsErrorCode . ScriptEvalDisabled :
145- throw new JsScriptException ( error , JsValue . Invalid , "Eval of strings is disabled in this runtime." ) ;
145+ throw new JsScriptException ( errorCode , JsValue . Invalid , "Eval of strings is disabled in this runtime." ) ;
146146
147147 #endregion
148148
149149 #region Fatal
150150
151151 case JsErrorCode . Fatal :
152- throw new JsFatalException ( error , "Fatal error." ) ;
152+ throw new JsFatalException ( errorCode , "Fatal error." ) ;
153153
154154 case JsErrorCode . WrongRuntime :
155- throw new JsFatalException ( error , "Wrong runtime." ) ;
155+ throw new JsFatalException ( errorCode , "Wrong runtime." ) ;
156156
157157 #endregion
158158
159159 default :
160- throw new JsFatalException ( error ) ;
160+ throw new JsFatalException ( errorCode ) ;
161161 }
162162 }
163163 }
@@ -257,21 +257,5 @@ public static JsValue CreateUriError(string message)
257257
258258 return errorValue ;
259259 }
260-
261- /// <summary>
262- /// Sets a exception
263- /// </summary>
264- /// <remarks>
265- /// Requires an active script context.
266- /// </remarks>
267- /// <param name="exception">The error object</param>
268- public static void SetException ( JsValue exception )
269- {
270- JsErrorCode innerError = NativeMethods . JsSetException ( exception ) ;
271- if ( innerError != JsErrorCode . NoError )
272- {
273- throw new JsFatalException ( innerError ) ;
274- }
275- }
276260 }
277261}
0 commit comments