Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b2c77ec

Browse filesBrowse files
cjihrigBridgeAR
authored andcommitted
report: use triggerReport() to handle exceptions
This commit uses the triggerReport() binding to handle uncaught exceptions and removes the custom onUncaughtException function. PR-URL: #26386 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 851a691 commit b2c77ec
Copy full SHA for b2c77ec

File tree

Expand file treeCollapse file tree

3 files changed

+12
-25
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-25
lines changed
Open diff view settings
Collapse file

‎lib/internal/process/execution.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/execution.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ function createFatalException() {
116116
report.syncConfig(config, false);
117117
if (Array.isArray(config.events) &&
118118
config.events.includes('exception')) {
119-
report.onUnCaughtException(er ? er.stack : undefined);
119+
report.triggerReport(er ? er.message : 'Exception',
120+
'Exception',
121+
null,
122+
er ? er.stack : undefined);
120123
}
121124
}
122125
} catch {} // Ignore the exception. Diagnostic reporting is unavailable.
Collapse file

‎lib/internal/process/report.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/report.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const report = {
8787
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
8888
}
8989

90-
return nr.triggerReport(file, err.stack);
90+
return nr.triggerReport('JavaScript API', 'API', file, err.stack);
9191
},
9292
getReport(err) {
9393
emitExperimentalWarning('report');
Collapse file

‎src/node_report_module.cc‎

Copy file name to clipboardExpand all lines: src/node_report_module.cc
+7-23Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ using v8::V8;
3535
using v8::Value;
3636

3737
// Internal/static function declarations
38-
void OnUncaughtException(const FunctionCallbackInfo<Value>& info);
3938
static void Initialize(Local<Object> exports,
4039
Local<Value> unused,
4140
Local<Context> context);
@@ -48,14 +47,16 @@ void TriggerReport(const FunctionCallbackInfo<Value>& info) {
4847
std::string filename;
4948
Local<String> stackstr;
5049

51-
CHECK_EQ(info.Length(), 2);
52-
stackstr = info[1].As<String>();
50+
CHECK_EQ(info.Length(), 4);
51+
String::Utf8Value message(isolate, info[0].As<String>());
52+
String::Utf8Value trigger(isolate, info[1].As<String>());
53+
stackstr = info[3].As<String>();
5354

54-
if (info[0]->IsString())
55-
filename = *String::Utf8Value(isolate, info[0]);
55+
if (info[2]->IsString())
56+
filename = *String::Utf8Value(isolate, info[2]);
5657

5758
filename = TriggerNodeReport(
58-
isolate, env, "JavaScript API", __func__, filename, stackstr);
59+
isolate, env, *message, *trigger, filename, stackstr);
5960
// Return value is the report filename
6061
info.GetReturnValue().Set(
6162
String::NewFromUtf8(isolate, filename.c_str(), v8::NewStringType::kNormal)
@@ -79,22 +80,6 @@ void GetReport(const FunctionCallbackInfo<Value>& info) {
7980
.ToLocalChecked());
8081
}
8182

82-
// Callbacks for triggering report on uncaught exception.
83-
// Calls triggered from JS land.
84-
void OnUncaughtException(const FunctionCallbackInfo<Value>& info) {
85-
Environment* env = Environment::GetCurrent(info);
86-
Isolate* isolate = env->isolate();
87-
HandleScope scope(isolate);
88-
std::string filename;
89-
std::shared_ptr<PerIsolateOptions> options = env->isolate_data()->options();
90-
91-
// Trigger report if requested
92-
if (options->report_uncaught_exception) {
93-
TriggerNodeReport(
94-
isolate, env, "exception", __func__, filename, info[0].As<String>());
95-
}
96-
}
97-
9883
// Signal handler for report action, called from JS land (util.js)
9984
void OnUserSignal(const FunctionCallbackInfo<Value>& info) {
10085
Environment* env = Environment::GetCurrent(info);
@@ -239,7 +224,6 @@ static void Initialize(Local<Object> exports,
239224
std::shared_ptr<PerIsolateOptions> options = env->isolate_data()->options();
240225
env->SetMethod(exports, "triggerReport", TriggerReport);
241226
env->SetMethod(exports, "getReport", GetReport);
242-
env->SetMethod(exports, "onUnCaughtException", OnUncaughtException);
243227
env->SetMethod(exports, "onUserSignal", OnUserSignal);
244228
env->SetMethod(exports, "syncConfig", SyncConfig);
245229
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.