MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix napi exception handler

+6 -9
+6 -9
src/modules/napi.c
··· 285 285 } 286 286 287 287 static napi_status napi_set_last(napi_env env, napi_status status, const char *message) { 288 - ant_napi_env_t *nenv = (ant_napi_env_t *)env; 289 - if (status == napi_ok && nenv && ( 290 - nenv->has_pending_exception 291 - || (nenv->js && nenv->js->thrown_exists) 292 - ) 293 - ) return napi_set_last_raw(env, napi_pending_exception, "pending exception"); 294 288 return napi_set_last_raw(env, status, message); 295 289 } 296 290 ··· 350 344 if (!nenv) return; 351 345 nenv->has_pending_exception = true; 352 346 nenv->pending_exception = exception; 353 - napi_set_last(env, napi_pending_exception, "pending exception"); 354 347 } 355 348 356 349 NAPI_EXTERN napi_status NAPI_CDECL napi_throw(napi_env env, napi_value error) { 357 350 ant_napi_env_t *nenv = (ant_napi_env_t *)env; 358 351 if (!nenv || !nenv->js) return napi_set_last(env, napi_invalid_arg, "invalid env"); 352 + if (nenv->has_pending_exception || nenv->js->thrown_exists) 353 + return napi_set_last(env, napi_pending_exception, "pending exception"); 359 354 js_throw(nenv->js, (ant_value_t)error); 360 355 napi_mark_pending_exception(env, error); 361 - return napi_pending_exception; 356 + return napi_set_last_raw(env, napi_ok, NULL); 362 357 } 363 358 364 359 static napi_status napi_check_pending_from_result(napi_env env, ant_value_t result) { ··· 370 365 env, 371 366 nenv->js->thrown_exists ? nenv->js->thrown_value : result 372 367 ); 368 + napi_set_last_raw(env, napi_pending_exception, "pending exception"); 373 369 return napi_pending_exception; 374 370 } 375 371 return napi_set_last(env, napi_ok, NULL); ··· 380 376 if (!nenv || !nenv->js) return napi_set_last(env, napi_invalid_arg, "invalid env"); 381 377 382 378 if (nenv->has_pending_exception) { 383 - napi_set_last(env, napi_pending_exception, "pending exception"); 379 + napi_set_last_raw(env, napi_pending_exception, "pending exception"); 384 380 return napi_pending_exception; 385 381 } 386 382 387 383 if (nenv->js->thrown_exists) { 388 384 napi_mark_pending_exception(env, (napi_value)nenv->js->thrown_value); 385 + napi_set_last_raw(env, napi_pending_exception, "pending exception"); 389 386 return napi_pending_exception; 390 387 } 391 388