Skip to content

Commit 48035a2

Browse files
danbevcodebytere
authored andcommitted
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: #33514 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 3559471 commit 48035a2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/api/environment.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,11 @@ static MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
4848
Local<Array> trace) {
4949
Environment* env = Environment::GetCurrent(context);
5050
if (env == nullptr) {
51-
MaybeLocal<String> s = exception->ToString(context);
52-
return s.IsEmpty() ?
53-
MaybeLocal<Value>() :
54-
MaybeLocal<Value>(s.ToLocalChecked());
51+
return exception->ToString(context).FromMaybe(Local<Value>());
5552
}
5653
Local<Function> prepare = env->prepare_stack_trace_callback();
5754
if (prepare.IsEmpty()) {
58-
MaybeLocal<String> s = exception->ToString(context);
59-
return s.IsEmpty() ?
60-
MaybeLocal<Value>() :
61-
MaybeLocal<Value>(s.ToLocalChecked());
55+
return exception->ToString(context).FromMaybe(Local<Value>());
6256
}
6357
Local<Value> args[] = {
6458
context->Global(),

0 commit comments

Comments
 (0)