src: handle exceptions from ToDetailString()
These methods may fail if execution is terminating. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
890223dede
commit
626f243747
@ -180,7 +180,8 @@ void PrintException(Isolate* isolate,
|
|||||||
Local<Value> err,
|
Local<Value> err,
|
||||||
Local<Message> message) {
|
Local<Message> message) {
|
||||||
node::Utf8Value reason(isolate,
|
node::Utf8Value reason(isolate,
|
||||||
err->ToDetailString(context).ToLocalChecked());
|
err->ToDetailString(context)
|
||||||
|
.FromMaybe(Local<String>()));
|
||||||
bool added_exception_line = false;
|
bool added_exception_line = false;
|
||||||
std::string source =
|
std::string source =
|
||||||
GetErrorSource(isolate, context, message, &added_exception_line);
|
GetErrorSource(isolate, context, message, &added_exception_line);
|
||||||
|
@ -125,8 +125,10 @@ static void PreviewEntries(const FunctionCallbackInfo<Value>& args) {
|
|||||||
|
|
||||||
// Side effect-free stringification that will never throw exceptions.
|
// Side effect-free stringification that will never throw exceptions.
|
||||||
static void SafeToString(const FunctionCallbackInfo<Value>& args) {
|
static void SafeToString(const FunctionCallbackInfo<Value>& args) {
|
||||||
auto context = args.GetIsolate()->GetCurrentContext();
|
Local<Context> context = args.GetIsolate()->GetCurrentContext();
|
||||||
args.GetReturnValue().Set(args[0]->ToDetailString(context).ToLocalChecked());
|
Local<String> detail_string;
|
||||||
|
if (args[0]->ToDetailString(context).ToLocal(&detail_string))
|
||||||
|
args.GetReturnValue().Set(detail_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Local<Private> IndexToPrivateSymbol(Environment* env, uint32_t index) {
|
inline Local<Private> IndexToPrivateSymbol(Environment* env, uint32_t index) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user