|
22 | 22 | #include "udp_wrap.h" |
23 | 23 | #include "env-inl.h" |
24 | 24 | #include "node_buffer.h" |
| 25 | +#include "node_errors.h" |
25 | 26 | #include "node_sockaddr-inl.h" |
26 | 27 | #include "handle_wrap.h" |
27 | 28 | #include "req_wrap-inl.h" |
28 | 29 | #include "util-inl.h" |
29 | 30 |
|
30 | 31 | namespace node { |
31 | 32 |
|
| 33 | +using errors::TryCatchScope; |
32 | 34 | using v8::Array; |
33 | 35 | using v8::ArrayBuffer; |
34 | 36 | using v8::BackingStore; |
@@ -729,10 +731,32 @@ void UDPWrap::OnRecv(ssize_t nread, |
729 | 731 | } |
730 | 732 |
|
731 | 733 | Local<Object> address; |
732 | | - if (!AddressToJS(env, addr).ToLocal(&address)) return; |
| 734 | + { |
| 735 | + TryCatchScope try_catch(env); |
| 736 | + try_catch.SetVerbose(true); |
| 737 | + DCHECK(try_catch.IsVerbose()); |
| 738 | + if (!AddressToJS(env, addr).ToLocal(&address)) { |
| 739 | + DCHECK(try_catch.HasCaught() && !try_catch.HasTerminated()); |
| 740 | + argv[2] = try_catch.Exception(); |
| 741 | + DCHECK(!argv[2].IsEmpty()); |
| 742 | + MakeCallback(env->onerror_string(), arraysize(argv), argv); |
| 743 | + return; |
| 744 | + } |
| 745 | + } |
733 | 746 |
|
734 | 747 | Local<ArrayBuffer> ab = ArrayBuffer::New(isolate, std::move(bs)); |
735 | | - argv[2] = Buffer::New(env, ab, 0, ab->ByteLength()).ToLocalChecked(); |
| 748 | + { |
| 749 | + TryCatchScope try_catch(env); |
| 750 | + try_catch.SetVerbose(true); |
| 751 | + DCHECK(try_catch.IsVerbose()); |
| 752 | + if (!Buffer::New(env, ab, 0, ab->ByteLength()).ToLocal(&argv[2])) { |
| 753 | + DCHECK(try_catch.HasCaught() && !try_catch.HasTerminated()); |
| 754 | + argv[2] = try_catch.Exception(); |
| 755 | + DCHECK(!argv[2].IsEmpty()); |
| 756 | + MakeCallback(env->onerror_string(), arraysize(argv), argv); |
| 757 | + return; |
| 758 | + } |
| 759 | + } |
736 | 760 | argv[3] = address; |
737 | 761 | MakeCallback(env->onmessage_string(), arraysize(argv), argv); |
738 | 762 | } |
|
0 commit comments