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 authored and codebytere committed Jun 18, 2020
1 parent 5bef20c commit 7e351f1
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
Expand Up @@ -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(),
Expand Down

0 comments on commit 7e351f1

Please sign in to comment.