Commit 14061979 authored by jgruber's avatar jgruber Committed by Commit bot

Port the second Factory::NewError variant

BUG=

Review-Url: https://codereview.chromium.org/2210463002
Cr-Commit-Position: refs/heads/master@{#38296}
parent 2fc2bbdd
...@@ -1175,20 +1175,20 @@ Handle<Object> Factory::NewError(Handle<JSFunction> constructor, ...@@ -1175,20 +1175,20 @@ Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
Handle<Object> Factory::NewError(Handle<JSFunction> constructor, Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
Handle<String> message) { Handle<String> message) {
Handle<Object> argv[] = { message }; // Construct a new error object. If an exception is thrown, use the exception
// as the result.
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result. Handle<Object> no_caller;
Handle<Object> result; MaybeHandle<Object> maybe_error =
MaybeHandle<Object> exception; ErrorUtils::Construct(isolate(), constructor, constructor, message,
if (!Execution::TryCall(isolate(), constructor, undefined_value(), SKIP_NONE, no_caller, false);
arraysize(argv), argv, &exception) if (maybe_error.is_null()) {
.ToHandle(&result)) { DCHECK(isolate()->has_pending_exception());
Handle<Object> exception_obj; maybe_error = handle(isolate()->pending_exception(), isolate());
if (exception.ToHandle(&exception_obj)) return exception_obj; isolate()->clear_pending_exception();
return undefined_value();
} }
return result;
return maybe_error.ToHandleChecked();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment