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,
Handle<Object> Factory::NewError(Handle<JSFunction> constructor,
Handle<String> message) {
Handle<Object> argv[] = { message };
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result.
Handle<Object> result;
MaybeHandle<Object> exception;
if (!Execution::TryCall(isolate(), constructor, undefined_value(),
arraysize(argv), argv, &exception)
.ToHandle(&result)) {
Handle<Object> exception_obj;
if (exception.ToHandle(&exception_obj)) return exception_obj;
return undefined_value();
// Construct a new error object. If an exception is thrown, use the exception
// as the result.
Handle<Object> no_caller;
MaybeHandle<Object> maybe_error =
ErrorUtils::Construct(isolate(), constructor, constructor, message,
SKIP_NONE, no_caller, false);
if (maybe_error.is_null()) {
DCHECK(isolate()->has_pending_exception());
maybe_error = handle(isolate()->pending_exception(), isolate());
isolate()->clear_pending_exception();
}
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