summaryrefslogtreecommitdiff
path: root/src/node_report_module.cc
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-03-01 17:10:25 -0500
committercjihrig <cjihrig@gmail.com>2019-03-03 19:25:46 -0500
commit48ab54c3237753397bb03f6a931247a6d8b031bf (patch)
tree6029c03cd9b87ce59adc967e1e3deaf285031a79 /src/node_report_module.cc
parent28db96f31c2724b16d6b9bec19c600023365b7cc (diff)
downloadnode-new-48ab54c3237753397bb03f6a931247a6d8b031bf.tar.gz
report: use triggerReport() to handle exceptions
This commit uses the triggerReport() binding to handle uncaught exceptions and removes the custom onUncaughtException function. PR-URL: https://github.com/nodejs/node/pull/26386 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_report_module.cc')
-rw-r--r--src/node_report_module.cc30
1 files changed, 7 insertions, 23 deletions
diff --git a/src/node_report_module.cc b/src/node_report_module.cc
index 0e3f8981b7..127e3258a8 100644
--- a/src/node_report_module.cc
+++ b/src/node_report_module.cc
@@ -35,7 +35,6 @@ using v8::V8;
using v8::Value;
// Internal/static function declarations
-void OnUncaughtException(const FunctionCallbackInfo<Value>& info);
static void Initialize(Local<Object> exports,
Local<Value> unused,
Local<Context> context);
@@ -48,14 +47,16 @@ void TriggerReport(const FunctionCallbackInfo<Value>& info) {
std::string filename;
Local<String> stackstr;
- CHECK_EQ(info.Length(), 2);
- stackstr = info[1].As<String>();
+ CHECK_EQ(info.Length(), 4);
+ String::Utf8Value message(isolate, info[0].As<String>());
+ String::Utf8Value trigger(isolate, info[1].As<String>());
+ stackstr = info[3].As<String>();
- if (info[0]->IsString())
- filename = *String::Utf8Value(isolate, info[0]);
+ if (info[2]->IsString())
+ filename = *String::Utf8Value(isolate, info[2]);
filename = TriggerNodeReport(
- isolate, env, "JavaScript API", __func__, filename, stackstr);
+ isolate, env, *message, *trigger, filename, stackstr);
// Return value is the report filename
info.GetReturnValue().Set(
String::NewFromUtf8(isolate, filename.c_str(), v8::NewStringType::kNormal)
@@ -79,22 +80,6 @@ void GetReport(const FunctionCallbackInfo<Value>& info) {
.ToLocalChecked());
}
-// Callbacks for triggering report on uncaught exception.
-// Calls triggered from JS land.
-void OnUncaughtException(const FunctionCallbackInfo<Value>& info) {
- Environment* env = Environment::GetCurrent(info);
- Isolate* isolate = env->isolate();
- HandleScope scope(isolate);
- std::string filename;
- std::shared_ptr<PerIsolateOptions> options = env->isolate_data()->options();
-
- // Trigger report if requested
- if (options->report_uncaught_exception) {
- TriggerNodeReport(
- isolate, env, "exception", __func__, filename, info[0].As<String>());
- }
-}
-
// Signal handler for report action, called from JS land (util.js)
void OnUserSignal(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
@@ -239,7 +224,6 @@ static void Initialize(Local<Object> exports,
std::shared_ptr<PerIsolateOptions> options = env->isolate_data()->options();
env->SetMethod(exports, "triggerReport", TriggerReport);
env->SetMethod(exports, "getReport", GetReport);
- env->SetMethod(exports, "onUnCaughtException", OnUncaughtException);
env->SetMethod(exports, "onUserSignal", OnUserSignal);
env->SetMethod(exports, "syncConfig", SyncConfig);
}