@@ -78,13 +78,44 @@ void ThrowJSError(const CallbackInfo& info) {
78
78
throw Error::New (info.Env (), message);
79
79
}
80
80
81
+ void ThrowTypeErrorCtor (const CallbackInfo& info) {
82
+ Napi::Value js_type_error = info[0 ];
83
+ ReleaseAndWaitForChildProcess (info, 1 );
84
+
85
+ throw Napi::TypeError (info.Env (), js_type_error);
86
+ }
87
+
81
88
void ThrowTypeError (const CallbackInfo& info) {
82
89
std::string message = info[0 ].As <String>().Utf8Value ();
83
90
84
91
ReleaseAndWaitForChildProcess (info, 1 );
85
92
throw TypeError::New (info.Env (), message);
86
93
}
87
94
95
+ void ThrowTypeErrorCStr (const CallbackInfo& info) {
96
+ std::string message = info[0 ].As <String>().Utf8Value ();
97
+
98
+ ReleaseAndWaitForChildProcess (info, 1 );
99
+ throw TypeError::New (info.Env (), message.c_str ());
100
+ }
101
+
102
+ void ThrowRangeErrorCStr (const CallbackInfo& info) {
103
+ std::string message = info[0 ].As <String>().Utf8Value ();
104
+ ReleaseAndWaitForChildProcess (info, 1 );
105
+ throw RangeError::New (info.Env (), message.c_str ());
106
+ }
107
+
108
+ void ThrowRangeErrorCtor (const CallbackInfo& info) {
109
+ Napi::Value js_range_err = info[0 ];
110
+ ReleaseAndWaitForChildProcess (info, 1 );
111
+ throw Napi::RangeError (info.Env (), js_range_err);
112
+ }
113
+
114
+ void ThrowEmptyRangeError (const CallbackInfo& info) {
115
+ ReleaseAndWaitForChildProcess (info, 1 );
116
+ throw RangeError ();
117
+ }
118
+
88
119
void ThrowRangeError (const CallbackInfo& info) {
89
120
std::string message = info[0 ].As <String>().Utf8Value ();
90
121
@@ -156,13 +187,44 @@ void ThrowTypeError(const CallbackInfo& info) {
156
187
TypeError::New (info.Env (), message).ThrowAsJavaScriptException ();
157
188
}
158
189
190
+ void ThrowTypeErrorCtor (const CallbackInfo& info) {
191
+ Napi::Value js_type_error = info[0 ];
192
+ ReleaseAndWaitForChildProcess (info, 1 );
193
+ TypeError (info.Env (), js_type_error).ThrowAsJavaScriptException ();
194
+ }
195
+
196
+ void ThrowTypeErrorCStr (const CallbackInfo& info) {
197
+ std::string message = info[0 ].As <String>().Utf8Value ();
198
+
199
+ ReleaseAndWaitForChildProcess (info, 1 );
200
+ TypeError::New (info.Env (), message.c_str ()).ThrowAsJavaScriptException ();
201
+ }
202
+
159
203
void ThrowRangeError (const CallbackInfo& info) {
160
204
std::string message = info[0 ].As <String>().Utf8Value ();
161
205
162
206
ReleaseAndWaitForChildProcess (info, 1 );
163
207
RangeError::New (info.Env (), message).ThrowAsJavaScriptException ();
164
208
}
165
209
210
+ void ThrowRangeErrorCtor (const CallbackInfo& info) {
211
+ Napi::Value js_range_err = info[0 ];
212
+ ReleaseAndWaitForChildProcess (info, 1 );
213
+ RangeError (info.Env (), js_range_err).ThrowAsJavaScriptException ();
214
+ }
215
+
216
+ void ThrowRangeErrorCStr (const CallbackInfo& info) {
217
+ std::string message = info[0 ].As <String>().Utf8Value ();
218
+ ReleaseAndWaitForChildProcess (info, 1 );
219
+ RangeError::New (info.Env (), message.c_str ()).ThrowAsJavaScriptException ();
220
+ }
221
+
222
+ // TODO: Figure out the correct api for this
223
+ void ThrowEmptyRangeError (const CallbackInfo& info) {
224
+ ReleaseAndWaitForChildProcess (info, 1 );
225
+ RangeError ().ThrowAsJavaScriptException ();
226
+ }
227
+
166
228
Value CatchError (const CallbackInfo& info) {
167
229
Function thrower = info[0 ].As <Function>();
168
230
thrower ({});
@@ -270,7 +332,12 @@ Object InitError(Env env) {
270
332
Function::New (env, LastExceptionErrorCode);
271
333
exports[" throwJSError" ] = Function::New (env, ThrowJSError);
272
334
exports[" throwTypeError" ] = Function::New (env, ThrowTypeError);
335
+ exports[" throwTypeErrorCtor" ] = Function::New (env, ThrowTypeErrorCtor);
336
+ exports[" throwTypeErrorCStr" ] = Function::New (env, ThrowTypeErrorCStr);
273
337
exports[" throwRangeError" ] = Function::New (env, ThrowRangeError);
338
+ exports[" throwRangeErrorCtor" ] = Function::New (env, ThrowRangeErrorCtor);
339
+ exports[" throwRangeErrorCStr" ] = Function::New (env, ThrowRangeErrorCStr);
340
+ exports[" throwEmptyRangeError" ] = Function::New (env, ThrowEmptyRangeError);
274
341
exports[" catchError" ] = Function::New (env, CatchError);
275
342
exports[" catchErrorMessage" ] = Function::New (env, CatchErrorMessage);
276
343
exports[" doNotCatch" ] = Function::New (env, DoNotCatch);
0 commit comments