diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-06-15 03:07:15 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2019-06-19 11:16:37 +0300 |
commit | a33c3c6d33fa81fa59a5aa95246d7f599e6abdd3 (patch) | |
tree | 16ee1009fda3317f5cdf3f8b80491f6b84b03d3e /src/js_stream.cc | |
parent | 1c23b6f2bec82904aacfff279f0e2776246b6da4 (diff) |
src: refactor uncaught exception handling
The C++ land `node::FatalException()` is not in fact fatal anymore.
It gives the user a chance to handle the uncaught exception
globally by listening to the `uncaughtException` event. This patch
renames it to `TriggerUncaughtException` in C++ to avoid the confusion.
In addition rename the JS land handler to `onGlobalUncaughtException`
to reflect its purpose - we have to keep the alias
`process._fatalException` and use that for now since it has been
monkey-patchable in the user land.
This patch also
- Adds more comments to the global uncaught exception handling routine
- Puts a few other C++ error handling functions into the `errors`
namespace
- Moves error-handling-related bindings to the `errors` binding.
Refs: https://github.com/nodejs/node/commit/2b252acea47af3ebeac3d7e68277f015667264cc
PR-URL: https://github.com/nodejs/node/pull/28257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Diffstat (limited to 'src/js_stream.cc')
-rw-r--r-- | src/js_stream.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/js_stream.cc b/src/js_stream.cc index 2663106ba7a..23bdb9b4892 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -49,7 +49,7 @@ bool JSStream::IsClosing() { Local<Value> value; if (!MakeCallback(env()->isclosing_string(), 0, nullptr).ToLocal(&value)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) - FatalException(env()->isolate(), try_catch); + errors::TriggerUncaughtException(env()->isolate(), try_catch); return true; } return value->IsTrue(); @@ -65,7 +65,7 @@ int JSStream::ReadStart() { if (!MakeCallback(env()->onreadstart_string(), 0, nullptr).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) - FatalException(env()->isolate(), try_catch); + errors::TriggerUncaughtException(env()->isolate(), try_catch); } return value_int; } @@ -80,7 +80,7 @@ int JSStream::ReadStop() { if (!MakeCallback(env()->onreadstop_string(), 0, nullptr).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) - FatalException(env()->isolate(), try_catch); + errors::TriggerUncaughtException(env()->isolate(), try_catch); } return value_int; } @@ -102,7 +102,7 @@ int JSStream::DoShutdown(ShutdownWrap* req_wrap) { argv).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) - FatalException(env()->isolate(), try_catch); + errors::TriggerUncaughtException(env()->isolate(), try_catch); } return value_int; } @@ -137,7 +137,7 @@ int JSStream::DoWrite(WriteWrap* w, argv).ToLocal(&value) || !value->Int32Value(env()->context()).To(&value_int)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) - FatalException(env()->isolate(), try_catch); + errors::TriggerUncaughtException(env()->isolate(), try_catch); } return value_int; } |