diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-19 12:40:27 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-26 19:03:14 +0800 |
commit | 744cdecbf42e9ba9bdff2d5006cb625f25b87917 (patch) | |
tree | 346a4870cb6c071c4d873cb5669ec27e9cbfd484 /src/api | |
parent | e029b927c2a291b78bb27202a14bff09628b75a6 (diff) | |
download | android-node-v8-744cdecbf42e9ba9bdff2d5006cb625f25b87917.tar.gz android-node-v8-744cdecbf42e9ba9bdff2d5006cb625f25b87917.tar.bz2 android-node-v8-744cdecbf42e9ba9bdff2d5006cb625f25b87917.zip |
src: move OnMessage to node_errors.cc
Rename the per-isolate message listener to `PerIsolateMessageListener`
and move it to `node_errors.cc` since it's part of the error
handling process. It also creates an external reference so it needs
to be exposed in `node_errors.h` for a snapshot builder to know.
PR-URL: https://github.com/nodejs/node/pull/27304
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/environment.cc | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc index 9a29ad1e5e..548b685dfe 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -5,7 +5,6 @@ #include "node_internals.h" #include "node_native_module_env.h" #include "node_platform.h" -#include "node_process.h" #include "node_v8_platform-inl.h" #include "uv.h" @@ -46,32 +45,6 @@ static bool ShouldAbortOnUncaughtException(Isolate* isolate) { !env->inside_should_not_abort_on_uncaught_scope(); } -static void OnMessage(Local<Message> message, Local<Value> error) { - Isolate* isolate = message->GetIsolate(); - switch (message->ErrorLevel()) { - case Isolate::MessageErrorLevel::kMessageWarning: { - Environment* env = Environment::GetCurrent(isolate); - if (!env) { - break; - } - Utf8Value filename(isolate, message->GetScriptOrigin().ResourceName()); - // (filename):(line) (message) - std::stringstream warning; - warning << *filename; - warning << ":"; - warning << message->GetLineNumber(env->context()).FromMaybe(-1); - warning << " "; - v8::String::Utf8Value msg(isolate, message->Get()); - warning << *msg; - USE(ProcessEmitWarningGeneric(env, warning.str().c_str(), "V8")); - break; - } - case Isolate::MessageErrorLevel::kMessageError: - FatalException(isolate, error, message); - break; - } -} - void* NodeArrayBufferAllocator::Allocate(size_t size) { if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers) return UncheckedCalloc(size); @@ -187,7 +160,7 @@ void SetIsolateUpForNode(v8::Isolate* isolate, IsolateSettingCategories cat) { switch (cat) { case IsolateSettingCategories::kErrorHandlers: isolate->AddMessageListenerWithErrorLevel( - OnMessage, + errors::PerIsolateMessageListener, Isolate::MessageErrorLevel::kMessageError | Isolate::MessageErrorLevel::kMessageWarning); isolate->SetAbortOnUncaughtExceptionCallback( |