summaryrefslogtreecommitdiff
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
parent28db96f31c2724b16d6b9bec19c600023365b7cc (diff)
downloadandroid-node-v8-48ab54c3237753397bb03f6a931247a6d8b031bf.tar.gz
android-node-v8-48ab54c3237753397bb03f6a931247a6d8b031bf.tar.bz2
android-node-v8-48ab54c3237753397bb03f6a931247a6d8b031bf.zip
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>
-rw-r--r--lib/internal/process/execution.js5
-rw-r--r--lib/internal/process/report.js2
-rw-r--r--src/node_report_module.cc30
3 files changed, 12 insertions, 25 deletions
diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js
index 575484d509..eb06dc0480 100644
--- a/lib/internal/process/execution.js
+++ b/lib/internal/process/execution.js
@@ -116,7 +116,10 @@ function createFatalException() {
report.syncConfig(config, false);
if (Array.isArray(config.events) &&
config.events.includes('exception')) {
- report.onUnCaughtException(er ? er.stack : undefined);
+ report.triggerReport(er ? er.message : 'Exception',
+ 'Exception',
+ null,
+ er ? er.stack : undefined);
}
}
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js
index 141a150a71..5d314cdeff 100644
--- a/lib/internal/process/report.js
+++ b/lib/internal/process/report.js
@@ -87,7 +87,7 @@ const report = {
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
}
- return nr.triggerReport(file, err.stack);
+ return nr.triggerReport('JavaScript API', 'API', file, err.stack);
},
getReport(err) {
emitExperimentalWarning('report');
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);
}