Skip to content

Commit

Permalink
src: use MaybeLocal::FromMaybe to return exception
Browse files Browse the repository at this point in the history
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: #33514
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
danbev committed May 25, 2020
1 parent 458677f commit c072124
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
@@ -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(),

0 comments on commit c072124

Please sign in to comment.