Skip to content

Commit

Permalink
Proxy errors include EINVAL errno.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolftimmermans committed Dec 17, 2019
1 parent 9706027 commit ed54323
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ Napi::Value Proxy::Run(const Napi::CallbackInfo& info) {
if (Env().IsExceptionPending()) return Env().Undefined();

if (front->endpoints == 0) {
Napi::Error::New(Env(), "Front-end socket must be bound or connected")
ErrnoException(Env(), EINVAL, "Front-end socket must be bound or connected")
.ThrowAsJavaScriptException();
return Env().Undefined();
}

if (back->endpoints == 0) {
Napi::Error::New(Env(), "Back-end socket must be bound or connected")
ErrnoException(Env(), EINVAL, "Back-end socket must be bound or connected")
.ThrowAsJavaScriptException();
return Env().Undefined();
}
Expand Down
4 changes: 4 additions & 0 deletions test/unit/proxy-run-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
} catch (err) {
assert.instanceOf(err, Error)
assert.equal(err.message, "Back-end socket must be bound or connected")
assert.equal(err.code, "EINVAL")
assert.typeOf(err.errno, "number")
}
})

Expand All @@ -70,6 +72,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
} catch (err) {
assert.instanceOf(err, Error)
assert.equal(err.message, "Back-end socket must be bound or connected")
assert.equal(err.code, "EINVAL")
assert.typeOf(err.errno, "number")
}
})
})
Expand Down

0 comments on commit ed54323

Please sign in to comment.