@@ -1406,16 +1406,15 @@ static void ReadLink(const FunctionCallbackInfo<Value>& args) {
1406
1406
const char * link_path = static_cast <const char *>(req_wrap_sync.req .ptr );
1407
1407
1408
1408
Local<Value> error;
1409
- MaybeLocal<Value> rc = StringBytes::Encode (isolate,
1410
- link_path,
1411
- encoding,
1412
- &error);
1413
- if (rc.IsEmpty ()) {
1409
+ Local<Value> ret;
1410
+ if (!StringBytes::Encode (isolate, link_path, encoding, &error)
1411
+ .ToLocal (&ret)) {
1412
+ DCHECK (!error.IsEmpty ());
1414
1413
env->isolate ()->ThrowException (error);
1415
1414
return ;
1416
1415
}
1417
1416
1418
- args.GetReturnValue ().Set (rc. ToLocalChecked () );
1417
+ args.GetReturnValue ().Set (ret );
1419
1418
}
1420
1419
}
1421
1420
@@ -1916,15 +1915,16 @@ static void MKDir(const FunctionCallbackInfo<Value>& args) {
1916
1915
}
1917
1916
if (!req_wrap_sync.continuation_data ()->first_path ().empty ()) {
1918
1917
Local<Value> error;
1918
+ Local<Value> ret;
1919
1919
std::string first_path (req_wrap_sync.continuation_data ()->first_path ());
1920
- MaybeLocal<Value> path = StringBytes::Encode (env-> isolate (),
1921
- first_path.c_str (),
1922
- UTF8, &error);
1923
- if (path .IsEmpty ()) {
1920
+ if (! StringBytes::Encode (
1921
+ env-> isolate (), first_path.c_str (), UTF8, &error)
1922
+ . ToLocal (&ret)) {
1923
+ DCHECK (!error .IsEmpty ());
1924
1924
env->isolate ()->ThrowException (error);
1925
1925
return ;
1926
1926
}
1927
- args.GetReturnValue ().Set (path. ToLocalChecked () );
1927
+ args.GetReturnValue ().Set (ret );
1928
1928
}
1929
1929
} else {
1930
1930
SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_mkdir, *path, mode);
@@ -1965,16 +1965,15 @@ static void RealPath(const FunctionCallbackInfo<Value>& args) {
1965
1965
const char * link_path = static_cast <const char *>(req_wrap_sync.req .ptr );
1966
1966
1967
1967
Local<Value> error;
1968
- MaybeLocal<Value> rc = StringBytes::Encode (isolate,
1969
- link_path,
1970
- encoding,
1971
- &error);
1972
- if (rc.IsEmpty ()) {
1968
+ Local<Value> ret;
1969
+ if (!StringBytes::Encode (isolate, link_path, encoding, &error)
1970
+ .ToLocal (&ret)) {
1971
+ DCHECK (!error.IsEmpty ());
1973
1972
env->isolate ()->ThrowException (error);
1974
1973
return ;
1975
1974
}
1976
1975
1977
- args.GetReturnValue ().Set (rc. ToLocalChecked () );
1976
+ args.GetReturnValue ().Set (ret );
1978
1977
}
1979
1978
}
1980
1979
@@ -2061,17 +2060,15 @@ static void ReadDir(const FunctionCallbackInfo<Value>& args) {
2061
2060
}
2062
2061
2063
2062
Local<Value> error;
2064
- MaybeLocal<Value> filename = StringBytes::Encode (isolate,
2065
- ent.name ,
2066
- encoding,
2067
- &error);
2068
-
2069
- if (filename.IsEmpty ()) {
2063
+ Local<Value> fn;
2064
+ if (!StringBytes::Encode (isolate, ent.name , encoding, &error)
2065
+ .ToLocal (&fn)) {
2066
+ DCHECK (!error.IsEmpty ());
2070
2067
isolate->ThrowException (error);
2071
2068
return ;
2072
2069
}
2073
2070
2074
- name_v.push_back (filename. ToLocalChecked () );
2071
+ name_v.push_back (fn );
2075
2072
2076
2073
if (with_types) {
2077
2074
type_v.emplace_back (Integer::New (isolate, ent.type ));
@@ -3092,13 +3089,14 @@ static void Mkdtemp(const FunctionCallbackInfo<Value>& args) {
3092
3089
return ;
3093
3090
}
3094
3091
Local<Value> error;
3095
- MaybeLocal<Value> rc =
3096
- StringBytes::Encode (isolate, req_wrap_sync.req .path , encoding, &error);
3097
- if (rc.IsEmpty ()) {
3092
+ Local<Value> ret;
3093
+ if (!StringBytes::Encode (isolate, req_wrap_sync.req .path , encoding, &error)
3094
+ .ToLocal (&ret)) {
3095
+ DCHECK (!error.IsEmpty ());
3098
3096
env->isolate ()->ThrowException (error);
3099
3097
return ;
3100
3098
}
3101
- args.GetReturnValue ().Set (rc. ToLocalChecked () );
3099
+ args.GetReturnValue ().Set (ret );
3102
3100
}
3103
3101
}
3104
3102
@@ -3410,9 +3408,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3410
3408
for (int i = 0 ; i < legacy_main_extensions_with_main_end; i++) {
3411
3409
file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
3412
3410
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
3413
- Local<Value> local_file_path =
3414
- Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3415
- .ToLocalChecked ();
3411
+ Local<Value> local_file_path;
3412
+ if (!Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3413
+ .ToLocal (&local_file_path)) {
3414
+ return ;
3415
+ }
3416
3416
BufferValue buff_file_path (isolate, local_file_path);
3417
3417
ToNamespacedPath (env, &buff_file_path);
3418
3418
@@ -3445,9 +3445,11 @@ void BindingData::LegacyMainResolve(const FunctionCallbackInfo<Value>& args) {
3445
3445
i++) {
3446
3446
file_path = *initial_file_path + std::string (legacy_main_extensions[i]);
3447
3447
// TODO(anonrig): Remove this when ToNamespacedPath supports std::string
3448
- Local<Value> local_file_path =
3449
- Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3450
- .ToLocalChecked ();
3448
+ Local<Value> local_file_path;
3449
+ if (!Buffer::Copy (env->isolate (), file_path.c_str (), file_path.size ())
3450
+ .ToLocal (&local_file_path)) {
3451
+ return ;
3452
+ }
3451
3453
BufferValue buff_file_path (isolate, local_file_path);
3452
3454
ToNamespacedPath (env, &buff_file_path);
3453
3455
0 commit comments