@@ -464,10 +464,10 @@ class Parser : public BaseObject, public StreamListener {
464
464
465
465
Local<Value> buffer = Buffer::Copy (env, at, length).ToLocalChecked ();
466
466
467
- MaybeLocal<Value> r =
468
- cb.As <Function>()->Call (env->context (), object (), 1 , &buffer);
467
+ v8::TryCatch try_catch (env-> isolate ());
468
+ USE ( cb.As <Function>()->Call (env->context (), object (), 1 , &buffer) );
469
469
470
- if (r. IsEmpty ()) {
470
+ if (try_catch. HasCaught ()) {
471
471
got_exception_ = true ;
472
472
llhttp_set_error_reason (&parser_, " HPE_JS_EXCEPTION:JS Exception" );
473
473
return HPE_USER;
@@ -503,9 +503,11 @@ class Parser : public BaseObject, public StreamListener {
503
503
if (!cb->IsFunction ())
504
504
return 0 ;
505
505
506
- MaybeLocal<Value> r =
507
- cb.As <Function>()->Call (env ()->context (), object (), 0 , nullptr );
508
- if (r.IsEmpty ()) {
506
+
507
+ v8::TryCatch try_catch (env ()->isolate ());
508
+ USE (cb.As <Function>()->Call (env ()->context (), object (), 0 , nullptr ));
509
+
510
+ if (try_catch.HasCaught ()) {
509
511
got_exception_ = true ;
510
512
return -1 ;
511
513
}
@@ -782,8 +784,14 @@ class Parser : public BaseObject, public StreamListener {
782
784
current_buffer_len_ = nread;
783
785
current_buffer_data_ = buf.base ;
784
786
787
+ v8::TryCatch try_catch (env ()->isolate ());
785
788
USE (cb.As <Function>()->Call (env ()->context (), object (), 1 , &ret));
786
789
790
+ if (try_catch.HasCaught ()) {
791
+ got_exception_ = true ;
792
+ return ;
793
+ }
794
+
787
795
current_buffer_len_ = 0 ;
788
796
current_buffer_data_ = nullptr ;
789
797
}
@@ -897,10 +905,12 @@ class Parser : public BaseObject, public StreamListener {
897
905
url_.ToString (env ())
898
906
};
899
907
900
- if (cb.As <Function>()
901
- ->Call (env ()->context (), object (), arraysize (argv), argv)
902
- .IsEmpty ())
908
+ v8::TryCatch try_catch (env ()->isolate ());
909
+ USE (cb.As <Function>()->Call (env ()->context (), object (), arraysize (argv), argv));
910
+
911
+ if (try_catch.HasCaught ()) {
903
912
got_exception_ = true ;
913
+ }
904
914
905
915
url_.Reset ();
906
916
have_flushed_ = true ;
0 commit comments