9
9
10
10
namespace node {
11
11
12
+ using errors::TryCatchScope;
12
13
using v8::Context;
13
14
using v8::Exception;
14
15
using v8::Function;
@@ -201,8 +202,10 @@ void ReportException(Environment* env,
201
202
} else {
202
203
Local<Object> err_obj = er->ToObject (env->context ()).ToLocalChecked ();
203
204
204
- trace_value = err_obj->Get (env->context (),
205
- env->stack_string ()).ToLocalChecked ();
205
+ if (!err_obj->Get (env->context (), env->stack_string ())
206
+ .ToLocal (&trace_value)) {
207
+ trace_value = Undefined (env->isolate ());
208
+ }
206
209
arrow =
207
210
err_obj->GetPrivate (env->context (), env->arrow_message_private_symbol ())
208
211
.ToLocalChecked ();
@@ -222,27 +225,25 @@ void ReportException(Environment* env,
222
225
// this really only happens for RangeErrors, since they're the only
223
226
// kind that won't have all this info in the trace, or when non-Error
224
227
// objects are thrown manually.
225
- Local <Value> message;
226
- Local <Value> name;
228
+ MaybeLocal <Value> message;
229
+ MaybeLocal <Value> name;
227
230
228
231
if (er->IsObject ()) {
229
232
Local<Object> err_obj = er.As <Object>();
230
- message = err_obj->Get (env->context (),
231
- env->message_string ()).ToLocalChecked ();
232
- name = err_obj->Get (env->context (),
233
- FIXED_ONE_BYTE_STRING (env->isolate (), " name" )).ToLocalChecked ();
233
+ message = err_obj->Get (env->context (), env->message_string ());
234
+ name = err_obj->Get (env->context (), env->name_string ());
234
235
}
235
236
236
- if (message.IsEmpty () || message->IsUndefined () || name. IsEmpty () ||
237
- name->IsUndefined ()) {
237
+ if (message.IsEmpty () || message. ToLocalChecked () ->IsUndefined () ||
238
+ name. IsEmpty () || name. ToLocalChecked () ->IsUndefined ()) {
238
239
// Not an error object. Just print as-is.
239
240
String::Utf8Value message (env->isolate (), er);
240
241
241
242
PrintErrorString (" %s\n " ,
242
243
*message ? *message : " <toString() threw exception>" );
243
244
} else {
244
- node::Utf8Value name_string (env->isolate (), name);
245
- node::Utf8Value message_string (env->isolate (), message);
245
+ node::Utf8Value name_string (env->isolate (), name. ToLocalChecked () );
246
+ node::Utf8Value message_string (env->isolate (), message. ToLocalChecked () );
246
247
247
248
if (arrow.IsEmpty () || !arrow->IsString () || decorated) {
248
249
PrintErrorString (" %s: %s\n " , *name_string, *message_string);
@@ -681,8 +682,8 @@ void DecorateErrorStack(Environment* env,
681
682
if (IsExceptionDecorated (env, err_obj)) return ;
682
683
683
684
AppendExceptionLine (env, exception , try_catch.Message (), CONTEXTIFY_ERROR);
684
- Local<Value> stack =
685
- err_obj->Get (env->context (), env->stack_string ()). ToLocalChecked ( );
685
+ TryCatchScope try_catch_scope (env); // Ignore exceptions below.
686
+ MaybeLocal<Value> stack = err_obj->Get (env->context (), env->stack_string ());
686
687
MaybeLocal<Value> maybe_value =
687
688
err_obj->GetPrivate (env->context (), env->arrow_message_private_symbol ());
688
689
@@ -691,7 +692,7 @@ void DecorateErrorStack(Environment* env,
691
692
return ;
692
693
}
693
694
694
- if (stack.IsEmpty () || !stack->IsString ()) {
695
+ if (stack.IsEmpty () || !stack. ToLocalChecked () ->IsString ()) {
695
696
return ;
696
697
}
697
698
@@ -700,8 +701,8 @@ void DecorateErrorStack(Environment* env,
700
701
String::Concat (env->isolate (),
701
702
arrow.As <String>(),
702
703
FIXED_ONE_BYTE_STRING (env->isolate (), " \n " )),
703
- stack.As <String>());
704
- err_obj->Set (env->context (), env->stack_string (), decorated_stack). FromJust ( );
704
+ stack.ToLocalChecked (). As <String>());
705
+ USE ( err_obj->Set (env->context (), env->stack_string (), decorated_stack));
705
706
err_obj->SetPrivate (
706
707
env->context (), env->decorated_private_symbol (), True (env->isolate ()));
707
708
}
0 commit comments