Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: src/factory.cc

Issue 2210463002: Port the second Factory::NewError variant (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@port-no-sideeffect-to-string
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index acfa5255c49e828c87d5f32359b2569b591682aa..b4d9de0fd157da66fe3400738ca44a73e4759ffc 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698