diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2020-05-22 15:25:36 +0300 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2020-05-25 12:31:14 +0300 |
commit | c072124814ca45e2f51afe0d5e202b0df6db9b4b (patch) | |
tree | 8c8d8b5177ff22bd5801a390155c5a16557ab250 /src/api | |
parent | 458677f5ef2bd35da920246bb266502ea76bb66c (diff) |
src: use MaybeLocal::FromMaybe to return exception
This commit suggests using MaybeLocal::FromMaybe to return the exception
string, passing in a default value (an empty Local<Value>) which will be
used if the exception object is empty.
PR-URL: https://github.com/nodejs/node/pull/33514
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/environment.cc | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/api/environment.cc b/src/api/environment.cc index 2b7a7023b5f..99b185798a7 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -51,17 +51,11 @@ static MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context, Local<Array> trace) { Environment* env = Environment::GetCurrent(context); if (env == nullptr) { - MaybeLocal<String> s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal<Value>() : - MaybeLocal<Value>(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local<Value>()); } Local<Function> prepare = env->prepare_stack_trace_callback(); if (prepare.IsEmpty()) { - MaybeLocal<String> s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal<Value>() : - MaybeLocal<Value>(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local<Value>()); } Local<Value> args[] = { context->Global(), |