Skip to content

Commit

Permalink
throw better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 16, 2024
1 parent 590b308 commit ec1f364
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/raw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ NAN_METHOD(SocketWrap::GetOption) {
(val ? val : (SOCKET_OPT_TYPE) &ival), &len);

if (rc == SOCKET_ERROR) {
Nan::ThrowError(raw_strerror (SOCKET_ERRNO));
Nan::ThrowError(node::ErrnoException(isolate, SOCKET_ERRNO, "getsockopt", ""));
return;
}

Expand All @@ -567,9 +567,7 @@ void SocketWrap::HandleIOEvent (int status, int revents) {
** be a structure. This causes issues when working with both Node.js
** 0.10 and 0.12. So, for now, we will just give you the number.
**/
char status_str[32];
sprintf(status_str, "%d", status);
args[1] = Nan::Error(status_str);
args[1] = node::ErrnoException(isolate, abs(status), "epoll", "");

cb->Call (context, handle(), 2, args);
} else {
Expand Down Expand Up @@ -727,7 +725,7 @@ NAN_METHOD(SocketWrap::Recv) {
cb->Call (context, socket->handle(), 1, argv);
break;
}
Nan::ThrowError(raw_strerror (SOCKET_ERRNO));
Nan::ThrowError(node::ErrnoException(isolate, SOCKET_ERRNO, "recvfrom", ""));
return;
}

Expand Down Expand Up @@ -902,7 +900,7 @@ NAN_METHOD(SocketWrap::Send) {
info.GetReturnValue().Set(Nan::New<Boolean>(false));
return;
}
Nan::ThrowError(raw_strerror (SOCKET_ERRNO));
Nan::ThrowError(node::ErrnoException(isolate, SOCKET_ERRNO, "send", ""));
return;
}

Expand Down Expand Up @@ -977,7 +975,7 @@ NAN_METHOD(SocketWrap::SetOption) {
(val ? val : (SOCKET_OPT_TYPE) &ival), len);

if (rc == SOCKET_ERROR) {
Nan::ThrowError(raw_strerror(SOCKET_ERRNO));
Nan::ThrowError(node::ErrnoException(isolate, SOCKET_ERRNO, "setsockopt", ""));
return;
}

Expand Down

0 comments on commit ec1f364

Please sign in to comment.