Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index f1d81ddd5fefa38f3704d11a6c1c7478f97e46c5..bda34bdfacacbb369f5e8db2b18d03c6f38b1ec7 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -5483,21 +5483,15 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { |
} |
-static i::Handle<i::String> NewExternalStringHandle( |
- i::Isolate* isolate, |
- v8::String::ExternalStringResource* resource) { |
- // We do not expect this to fail. Change this if it does. |
- return isolate->factory()->NewExternalStringFromTwoByte( |
- resource).ToHandleChecked(); |
+static i::MaybeHandle<i::String> NewExternalStringHandle( |
+ i::Isolate* isolate, v8::String::ExternalStringResource* resource) { |
+ return isolate->factory()->NewExternalStringFromTwoByte(resource); |
} |
-static i::Handle<i::String> NewExternalOneByteStringHandle( |
+static i::MaybeHandle<i::String> NewExternalOneByteStringHandle( |
i::Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { |
- // We do not expect this to fail. Change this if it does. |
- return isolate->factory() |
- ->NewExternalStringFromOneByte(resource) |
- .ToHandleChecked(); |
+ return isolate->factory()->NewExternalStringFromOneByte(resource); |
} |
@@ -5508,9 +5502,13 @@ Local<String> v8::String::NewExternal( |
LOG_API(i_isolate, "String::NewExternal"); |
ENTER_V8(i_isolate); |
CHECK(resource && resource->data()); |
- i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
- i_isolate->heap()->external_string_table()->AddString(*result); |
- return Utils::ToLocal(result); |
+ EXCEPTION_PREAMBLE(i_isolate); |
+ i::Handle<i::String> string; |
+ has_pending_exception = |
+ !NewExternalStringHandle(i_isolate, resource).ToHandle(&string); |
+ EXCEPTION_BAILOUT_CHECK(i_isolate, Local<String>()); |
+ i_isolate->heap()->external_string_table()->AddString(*string); |
+ return Utils::ToLocal(string); |
} |
@@ -5546,10 +5544,13 @@ Local<String> v8::String::NewExternal( |
LOG_API(i_isolate, "String::NewExternal"); |
ENTER_V8(i_isolate); |
CHECK(resource && resource->data()); |
- i::Handle<i::String> result = |
- NewExternalOneByteStringHandle(i_isolate, resource); |
- i_isolate->heap()->external_string_table()->AddString(*result); |
- return Utils::ToLocal(result); |
+ EXCEPTION_PREAMBLE(i_isolate); |
+ i::Handle<i::String> string; |
+ has_pending_exception = |
+ !NewExternalOneByteStringHandle(i_isolate, resource).ToHandle(&string); |
+ EXCEPTION_BAILOUT_CHECK(i_isolate, Local<String>()); |
+ i_isolate->heap()->external_string_table()->AddString(*string); |
+ return Utils::ToLocal(string); |
} |