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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
danbev authored and codebytere committed Jul 8, 2020
1 parent 3559471 commit 48035a2
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 @@ -48,17 +48,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 48035a2

Please sign in to comment.