@@ -724,28 +724,29 @@ Local<Value> ErrnoException(Isolate* isolate,
724
724
}
725
725
Local<String> message = OneByteString (env->isolate (), msg);
726
726
727
- Local<String> cons1 =
727
+ Local<String> cons =
728
728
String::Concat (estring, FIXED_ONE_BYTE_STRING (env->isolate (), " , " ));
729
- Local<String> cons2 = String::Concat (cons1 , message);
729
+ cons = String::Concat (cons , message);
730
730
731
- if (path) {
732
- Local<String> cons3 =
733
- String::Concat (cons2, FIXED_ONE_BYTE_STRING (env->isolate (), " '" ));
734
- Local<String> cons4 =
735
- String::Concat (cons3, String::NewFromUtf8 (env->isolate (), path));
736
- Local<String> cons5 =
737
- String::Concat (cons4, FIXED_ONE_BYTE_STRING (env->isolate (), " '" ));
738
- e = Exception::Error (cons5);
739
- } else {
740
- e = Exception::Error (cons2);
731
+ Local<String> path_string;
732
+ if (path != nullptr ) {
733
+ // FIXME(bnoordhuis) It's questionable to interpret the file path as UTF-8.
734
+ path_string = String::NewFromUtf8 (env->isolate (), path);
741
735
}
742
736
737
+ if (path_string.IsEmpty () == false ) {
738
+ cons = String::Concat (cons, FIXED_ONE_BYTE_STRING (env->isolate (), " '" ));
739
+ cons = String::Concat (cons, path_string);
740
+ cons = String::Concat (cons, FIXED_ONE_BYTE_STRING (env->isolate (), " '" ));
741
+ }
742
+ e = Exception::Error (cons);
743
+
743
744
Local<Object> obj = e->ToObject (env->isolate ());
744
745
obj->Set (env->errno_string (), Integer::New (env->isolate (), errorno));
745
746
obj->Set (env->code_string (), estring);
746
747
747
- if (path != nullptr ) {
748
- obj->Set (env->path_string (), String::NewFromUtf8 (env-> isolate (), path) );
748
+ if (path_string. IsEmpty () == false ) {
749
+ obj->Set (env->path_string (), path_string );
749
750
}
750
751
751
752
if (syscall != nullptr ) {
0 commit comments