@@ -8,114 +8,114 @@ internal static class JsErrorHelpers
8
8
/// <summary>
9
9
/// Throws if a native method returns an error code
10
10
/// </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 )
13
13
{
14
- if ( error != JsErrorCode . NoError )
14
+ if ( errorCode != JsErrorCode . NoError )
15
15
{
16
- switch ( error )
16
+ switch ( errorCode )
17
17
{
18
18
#region Usage
19
19
20
20
case JsErrorCode . InvalidArgument :
21
- throw new JsUsageException ( error , "Invalid argument." ) ;
21
+ throw new JsUsageException ( errorCode , "Invalid argument." ) ;
22
22
23
23
case JsErrorCode . NullArgument :
24
- throw new JsUsageException ( error , "Null argument." ) ;
24
+ throw new JsUsageException ( errorCode , "Null argument." ) ;
25
25
26
26
case JsErrorCode . NoCurrentContext :
27
- throw new JsUsageException ( error , "No current context." ) ;
27
+ throw new JsUsageException ( errorCode , "No current context." ) ;
28
28
29
29
case JsErrorCode . InExceptionState :
30
- throw new JsUsageException ( error , "Runtime is in exception state." ) ;
30
+ throw new JsUsageException ( errorCode , "Runtime is in exception state." ) ;
31
31
32
32
case JsErrorCode . NotImplemented :
33
- throw new JsUsageException ( error , "Method is not implemented." ) ;
33
+ throw new JsUsageException ( errorCode , "Method is not implemented." ) ;
34
34
35
35
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." ) ;
37
37
38
38
case JsErrorCode . RuntimeInUse :
39
- throw new JsUsageException ( error , "Runtime is in use." ) ;
39
+ throw new JsUsageException ( errorCode , "Runtime is in use." ) ;
40
40
41
41
case JsErrorCode . BadSerializedScript :
42
- throw new JsUsageException ( error , "Bad serialized script." ) ;
42
+ throw new JsUsageException ( errorCode , "Bad serialized script." ) ;
43
43
44
44
case JsErrorCode . InDisabledState :
45
- throw new JsUsageException ( error , "Runtime is disabled." ) ;
45
+ throw new JsUsageException ( errorCode , "Runtime is disabled." ) ;
46
46
47
47
case JsErrorCode . CannotDisableExecution :
48
- throw new JsUsageException ( error , "Cannot disable execution." ) ;
48
+ throw new JsUsageException ( errorCode , "Cannot disable execution." ) ;
49
49
50
50
case JsErrorCode . HeapEnumInProgress :
51
- throw new JsUsageException ( error , "Heap enumeration is in progress." ) ;
51
+ throw new JsUsageException ( errorCode , "Heap enumeration is in progress." ) ;
52
52
53
53
case JsErrorCode . ArgumentNotObject :
54
- throw new JsUsageException ( error , "Argument is not an object." ) ;
54
+ throw new JsUsageException ( errorCode , "Argument is not an object." ) ;
55
55
56
56
case JsErrorCode . InProfileCallback :
57
- throw new JsUsageException ( error , "In a profile callback." ) ;
57
+ throw new JsUsageException ( errorCode , "In a profile callback." ) ;
58
58
59
59
case JsErrorCode . InThreadServiceCallback :
60
- throw new JsUsageException ( error , "In a thread service callback." ) ;
60
+ throw new JsUsageException ( errorCode , "In a thread service callback." ) ;
61
61
62
62
case JsErrorCode . CannotSerializeDebugScript :
63
- throw new JsUsageException ( error , "Cannot serialize a debug script." ) ;
63
+ throw new JsUsageException ( errorCode , "Cannot serialize a debug script." ) ;
64
64
65
65
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." ) ;
67
67
68
68
case JsErrorCode . AlreadyProfilingContext :
69
- throw new JsUsageException ( error , "Already profiling this context." ) ;
69
+ throw new JsUsageException ( errorCode , "Already profiling this context." ) ;
70
70
71
71
case JsErrorCode . IdleNotEnabled :
72
- throw new JsUsageException ( error , "Idle is not enabled." ) ;
72
+ throw new JsUsageException ( errorCode , "Idle is not enabled." ) ;
73
73
74
74
case JsErrorCode . CannotSetProjectionEnqueueCallback :
75
- throw new JsUsageException ( error , "Cannot set projection enqueue callback." ) ;
75
+ throw new JsUsageException ( errorCode , "Cannot set projection enqueue callback." ) ;
76
76
77
77
case JsErrorCode . CannotStartProjection :
78
- throw new JsUsageException ( error , "Cannot start projection." ) ;
78
+ throw new JsUsageException ( errorCode , "Cannot start projection." ) ;
79
79
80
80
case JsErrorCode . InObjectBeforeCollectCallback :
81
- throw new JsUsageException ( error , "In object before collect callback." ) ;
81
+ throw new JsUsageException ( errorCode , "In object before collect callback." ) ;
82
82
83
83
case JsErrorCode . ObjectNotInspectable :
84
- throw new JsUsageException ( error , "Object not inspectable." ) ;
84
+ throw new JsUsageException ( errorCode , "Object not inspectable." ) ;
85
85
86
86
case JsErrorCode . PropertyNotSymbol :
87
- throw new JsUsageException ( error , "Property not symbol." ) ;
87
+ throw new JsUsageException ( errorCode , "Property not symbol." ) ;
88
88
89
89
case JsErrorCode . PropertyNotString :
90
- throw new JsUsageException ( error , "Property not string." ) ;
90
+ throw new JsUsageException ( errorCode , "Property not string." ) ;
91
91
92
92
case JsErrorCode . InvalidContext :
93
- throw new JsUsageException ( error , "Invalid context." ) ;
93
+ throw new JsUsageException ( errorCode , "Invalid context." ) ;
94
94
95
95
case JsErrorCode . InvalidModuleHostInfoKind :
96
- throw new JsUsageException ( error , "Invalid module host info kind." ) ;
96
+ throw new JsUsageException ( errorCode , "Invalid module host info kind." ) ;
97
97
98
98
case JsErrorCode . ModuleParsed :
99
- throw new JsUsageException ( error , "Module parsed." ) ;
99
+ throw new JsUsageException ( errorCode , "Module parsed." ) ;
100
100
101
101
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." ) ;
103
103
104
104
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." ) ;
106
106
107
107
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." ) ;
109
109
110
110
#endregion
111
111
112
112
#region Engine
113
113
114
114
case JsErrorCode . OutOfMemory :
115
- throw new JsEngineException ( error , "Out of memory." ) ;
115
+ throw new JsEngineException ( errorCode , "Out of memory." ) ;
116
116
117
117
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." ) ;
119
119
120
120
#endregion
121
121
@@ -125,39 +125,39 @@ public static void ThrowIfError(JsErrorCode error)
125
125
case JsErrorCode . ScriptCompile :
126
126
{
127
127
JsValue errorMetadata ;
128
- JsErrorCode innerError = NativeMethods . JsGetAndClearExceptionWithMetadata ( out errorMetadata ) ;
128
+ JsErrorCode innerErrorCode = NativeMethods . JsGetAndClearExceptionWithMetadata ( out errorMetadata ) ;
129
129
130
- if ( innerError != JsErrorCode . NoError )
130
+ if ( innerErrorCode != JsErrorCode . NoError )
131
131
{
132
- throw new JsFatalException ( innerError ) ;
132
+ throw new JsFatalException ( innerErrorCode ) ;
133
133
}
134
134
135
- string message = error == JsErrorCode . ScriptCompile ?
135
+ string message = errorCode == JsErrorCode . ScriptCompile ?
136
136
"Compile error." : "Script threw an exception." ;
137
137
138
- throw new JsScriptException ( error , errorMetadata , message ) ;
138
+ throw new JsScriptException ( errorCode , errorMetadata , message ) ;
139
139
}
140
140
141
141
case JsErrorCode . ScriptTerminated :
142
- throw new JsScriptException ( error , JsValue . Invalid , "Script was terminated." ) ;
142
+ throw new JsScriptException ( errorCode , JsValue . Invalid , "Script was terminated." ) ;
143
143
144
144
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." ) ;
146
146
147
147
#endregion
148
148
149
149
#region Fatal
150
150
151
151
case JsErrorCode . Fatal :
152
- throw new JsFatalException ( error , "Fatal error." ) ;
152
+ throw new JsFatalException ( errorCode , "Fatal error." ) ;
153
153
154
154
case JsErrorCode . WrongRuntime :
155
- throw new JsFatalException ( error , "Wrong runtime." ) ;
155
+ throw new JsFatalException ( errorCode , "Wrong runtime." ) ;
156
156
157
157
#endregion
158
158
159
159
default :
160
- throw new JsFatalException ( error ) ;
160
+ throw new JsFatalException ( errorCode ) ;
161
161
}
162
162
}
163
163
}
@@ -257,21 +257,5 @@ public static JsValue CreateUriError(string message)
257
257
258
258
return errorValue ;
259
259
}
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
- }
276
260
}
277
261
}
0 commit comments