@@ -240,7 +240,7 @@ namespace zmq {
240
240
241
241
Context::Context (int io_threads) : Nan::ObjectWrap() {
242
242
context_ = zmq_init (io_threads);
243
- if (!context_) throw std::runtime_error (ErrorMessage ());
243
+ if (!context_) Nan::ThrowError (ErrorMessage ());
244
244
}
245
245
246
246
Context *
@@ -251,7 +251,10 @@ namespace zmq {
251
251
void
252
252
Context::Close () {
253
253
if (context_ != NULL ) {
254
- if (zmq_term (context_) < 0 ) throw std::runtime_error (ErrorMessage ());
254
+ if (zmq_term (context_) < 0 ) {
255
+ Nan::ThrowError (ErrorMessage ());
256
+ return ;
257
+ }
255
258
context_ = NULL ;
256
259
}
257
260
}
@@ -371,8 +374,10 @@ namespace zmq {
371
374
if (rc < 0 ) {
372
375
if (zmq_errno ()==EINTR) {
373
376
continue ;
377
+ } else {
378
+ Nan::ThrowError (ErrorMessage ());
379
+ return -1 ;
374
380
}
375
- throw std::runtime_error (ErrorMessage ());
376
381
} else {
377
382
break ;
378
383
}
@@ -983,12 +988,12 @@ namespace zmq {
983
988
public:
984
989
inline MessageReference () {
985
990
if (zmq_msg_init (&msg_) < 0 )
986
- throw std::runtime_error (ErrorMessage ());
991
+ Nan::ThrowError (ErrorMessage ());
987
992
}
988
993
989
994
inline ~MessageReference () {
990
995
if (zmq_msg_close (&msg_) < 0 )
991
- throw std::runtime_error (ErrorMessage ());
996
+ Nan::ThrowError (ErrorMessage ());
992
997
}
993
998
994
999
inline operator zmq_msg_t *() {
@@ -1055,8 +1060,10 @@ namespace zmq {
1055
1060
zmq_socket_monitor (this ->socket_ , NULL , ZMQ_EVENT_ALL);
1056
1061
1057
1062
// Close the monitor socket and stop timer
1058
- if (zmq_close (this ->monitor_socket_ ) < 0 )
1059
- throw std::runtime_error (ErrorMessage ());
1063
+ if (zmq_close (this ->monitor_socket_ ) < 0 ) {
1064
+ Nan::ThrowError (ErrorMessage ());
1065
+ return ;
1066
+ }
1060
1067
uv_timer_stop (this ->monitor_handle_ );
1061
1068
this ->monitor_handle_ = NULL ;
1062
1069
this ->monitor_socket_ = NULL ;
@@ -1188,13 +1195,13 @@ namespace zmq {
1188
1195
if (zmq_msg_init_data (&msg_, Buffer::Data (buf), Buffer::Length (buf),
1189
1196
BufferReference::FreeCallback, bufref_) < 0 ) {
1190
1197
delete bufref_;
1191
- throw std::runtime_error (ErrorMessage ());
1198
+ Nan::ThrowError (ErrorMessage ());
1192
1199
}
1193
1200
};
1194
1201
1195
1202
inline ~OutgoingMessage () {
1196
1203
if (zmq_msg_close (&msg_) < 0 )
1197
- throw std::runtime_error (ErrorMessage ());
1204
+ Nan::ThrowError (ErrorMessage ());
1198
1205
};
1199
1206
1200
1207
inline operator zmq_msg_t *() {
@@ -1393,8 +1400,10 @@ namespace zmq {
1393
1400
void
1394
1401
Socket::Close () {
1395
1402
if (socket_) {
1396
- if (zmq_close (socket_) < 0 )
1397
- throw std::runtime_error (ErrorMessage ());
1403
+ if (zmq_close (socket_) < 0 ) {
1404
+ Nan::ThrowError (ErrorMessage ());
1405
+ return ;
1406
+ }
1398
1407
socket_ = NULL ;
1399
1408
state_ = STATE_CLOSED;
1400
1409
context_.Reset ();
0 commit comments