Add JS error for missing callback to sever#tryShutdown

This commit is contained in:
murgatroid99 2018-01-05 13:09:15 -08:00
parent 31b75d7f07
commit 843d063037
1 changed files with 3 additions and 0 deletions

View File

@ -312,6 +312,9 @@ NAN_METHOD(Server::TryShutdown) {
if (!HasInstance(info.This())) {
return Nan::ThrowTypeError("tryShutdown can only be called on a Server");
}
if (!info[0]->IsFunction()) {
return Nan::ThrowError("tryShutdown's argument must be a callback");
}
Server *server = ObjectWrap::Unwrap<Server>(info.This());
if (server->wrapped_server == NULL) {
// Server is already shut down. Call callback immediately.