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 8849eb2

Browse filesBrowse files
addaleaxBridgeAR
authored andcommitted
src: handle exceptions from ToDetailString()
These methods may fail if execution is terminating. PR-URL: #28019 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 8a032fc commit 8849eb2
Copy full SHA for 8849eb2

File tree

Expand file treeCollapse file tree

2 files changed

+6
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-3
lines changed
Open diff view settings
Collapse file

‎src/node_errors.cc‎

Copy file name to clipboardExpand all lines: src/node_errors.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void PrintException(Isolate* isolate,
180180
Local<Value> err,
181181
Local<Message> message) {
182182
node::Utf8Value reason(isolate,
183-
err->ToDetailString(context).ToLocalChecked());
183+
err->ToDetailString(context)
184+
.FromMaybe(Local<String>()));
184185
bool added_exception_line = false;
185186
std::string source =
186187
GetErrorSource(isolate, context, message, &added_exception_line);
Collapse file

‎src/node_util.cc‎

Copy file name to clipboardExpand all lines: src/node_util.cc
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
125125

126126
// Side effect-free stringification that will never throw exceptions.
127127
static void SafeToString(const FunctionCallbackInfo<Value>& args) {
128-
auto context = args.GetIsolate()->GetCurrentContext();
129-
args.GetReturnValue().Set(args[0]->ToDetailString(context).ToLocalChecked());
128+
Local<Context> context = args.GetIsolate()->GetCurrentContext();
129+
Local<String> detail_string;
130+
if (args[0]->ToDetailString(context).ToLocal(&detail_string))
131+
args.GetReturnValue().Set(detail_string);
130132
}
131133

132134
inline Local<Private> IndexToPrivateSymbol(Environment* env, uint32_t index) {

0 commit comments

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