From c072124814ca45e2f51afe0d5e202b0df6db9b4b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 22 May 2020 14:25:36 +0200 Subject: [PATCH] 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) which will be used if the exception object is empty. PR-URL: https://github.com/nodejs/node/pull/33514 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis --- src/api/environment.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 2b7a7023b5f33c..99b185798a7f9e 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -51,17 +51,11 @@ static MaybeLocal PrepareStackTraceCallback(Local context, Local trace) { Environment* env = Environment::GetCurrent(context); if (env == nullptr) { - MaybeLocal s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal() : - MaybeLocal(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local()); } Local prepare = env->prepare_stack_trace_callback(); if (prepare.IsEmpty()) { - MaybeLocal s = exception->ToString(context); - return s.IsEmpty() ? - MaybeLocal() : - MaybeLocal(s.ToLocalChecked()); + return exception->ToString(context).FromMaybe(Local()); } Local args[] = { context->Global(),