@@ -2760,27 +2760,26 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
27602760
27612761 const enum encoding encoding = ParseEncoding (isolate, args[1 ], UTF8);
27622762
2763- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2764- if ( req_wrap_async != nullptr ) { // mkdtemp(tmpl, encoding, req)
2763+ if (argc > 2 ) { // mkdtemp(tmpl, encoding, req)
2764+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
27652765 FS_ASYNC_TRACE_BEGIN1 (
27662766 UV_FS_MKDTEMP, req_wrap_async, " path" , TRACE_STR_COPY (*tmpl))
27672767 AsyncCall (env, req_wrap_async, args, " mkdtemp" , encoding, AfterStringPath,
27682768 uv_fs_mkdtemp, *tmpl);
2769- } else { // mkdtemp(tmpl, encoding, undefined, ctx)
2770- CHECK_EQ (argc, 4 );
2771- FSReqWrapSync req_wrap_sync;
2769+ } else { // mkdtemp(tmpl, encoding)
2770+ FSReqWrapSync req_wrap_sync (" mkdtemp" , *tmpl);
27722771 FS_SYNC_TRACE_BEGIN (mkdtemp);
2773- SyncCall (env, args[ 3 ], &req_wrap_sync, " mkdtemp " ,
2774- uv_fs_mkdtemp, *tmpl);
2772+ int result =
2773+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_mkdtemp, *tmpl);
27752774 FS_SYNC_TRACE_END (mkdtemp);
2776- const char * path = req_wrap_sync.req .path ;
2777-
2775+ if (is_uv_error (result)) {
2776+ return ;
2777+ }
27782778 Local<Value> error;
27792779 MaybeLocal<Value> rc =
2780- StringBytes::Encode (isolate, path, encoding, &error);
2780+ StringBytes::Encode (isolate, req_wrap_sync. req . path , encoding, &error);
27812781 if (rc.IsEmpty ()) {
2782- Local<Object> ctx = args[3 ].As <Object>();
2783- ctx->Set (env->context (), env->error_string (), error).Check ();
2782+ env->isolate ()->ThrowException (error);
27842783 return ;
27852784 }
27862785 args.GetReturnValue ().Set (rc.ToLocalChecked ());
0 commit comments