Commit f62653f9 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[isolate] Clean up MessageHandler::ReportMessage

- Use early return
- Add exception_string read-only root

Change-Id: Iba935a4a0308d21ced2693047fdf217b7f9e62f4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3097884Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76335}
parent 05ff5f0a
...@@ -106,7 +106,11 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc, ...@@ -106,7 +106,11 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc,
Handle<JSMessageObject> message) { Handle<JSMessageObject> message) {
v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
if (api_message_obj->ErrorLevel() == v8::Isolate::kMessageError) { if (api_message_obj->ErrorLevel() != v8::Isolate::kMessageError) {
ReportMessageNoExceptions(isolate, loc, message, v8::Local<v8::Value>());
return;
}
// We are calling into embedder's code which can throw exceptions. // We are calling into embedder's code which can throw exceptions.
// Thus we need to save current exception state, reset it to the clean one // Thus we need to save current exception state, reset it to the clean one
// and ignore scheduled exceptions callbacks can throw. // and ignore scheduled exceptions callbacks can throw.
...@@ -144,17 +148,13 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc, ...@@ -144,17 +148,13 @@ void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc,
DCHECK(isolate->has_pending_exception()); DCHECK(isolate->has_pending_exception());
isolate->clear_pending_exception(); isolate->clear_pending_exception();
isolate->set_external_caught_exception(false); isolate->set_external_caught_exception(false);
stringified = stringified = isolate->factory()->exception_string();
isolate->factory()->NewStringFromAsciiChecked("exception");
} }
message->set_argument(*stringified); message->set_argument(*stringified);
} }
v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception);
ReportMessageNoExceptions(isolate, loc, message, api_exception_obj); ReportMessageNoExceptions(isolate, loc, message, api_exception_obj);
} else {
ReportMessageNoExceptions(isolate, loc, message, v8::Local<v8::Value>());
}
} }
void MessageHandler::ReportMessageNoExceptions( void MessageHandler::ReportMessageNoExceptions(
......
...@@ -198,13 +198,14 @@ ...@@ -198,13 +198,14 @@
V(_, dot_string, ".") \ V(_, dot_string, ".") \
V(_, dot_switch_tag_string, ".switch_tag") \ V(_, dot_switch_tag_string, ".switch_tag") \
V(_, dotAll_string, "dotAll") \ V(_, dotAll_string, "dotAll") \
V(_, enumerable_string, "enumerable") \
V(_, element_string, "element") \
V(_, Error_string, "Error") \ V(_, Error_string, "Error") \
V(_, errors_string, "errors") \ V(_, EvalError_string, "EvalError") \
V(_, element_string, "element") \
V(_, enumerable_string, "enumerable") \
V(_, error_to_string, "[object Error]") \ V(_, error_to_string, "[object Error]") \
V(_, errors_string, "errors") \
V(_, eval_string, "eval") \ V(_, eval_string, "eval") \
V(_, EvalError_string, "EvalError") \ V(_, exception_string, "exception") \
V(_, exec_string, "exec") \ V(_, exec_string, "exec") \
V(_, false_string, "false") \ V(_, false_string, "false") \
V(_, FinalizationRegistry_string, "FinalizationRegistry") \ V(_, FinalizationRegistry_string, "FinalizationRegistry") \
......
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