Skip to content

Commit ed54323

Browse files
Proxy errors include EINVAL errno.
1 parent 9706027 commit ed54323

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/proxy.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ Napi::Value Proxy::Run(const Napi::CallbackInfo& info) {
5252
if (Env().IsExceptionPending()) return Env().Undefined();
5353

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

6060
if (back->endpoints == 0) {
61-
Napi::Error::New(Env(), "Back-end socket must be bound or connected")
61+
ErrnoException(Env(), EINVAL, "Back-end socket must be bound or connected")
6262
.ThrowAsJavaScriptException();
6363
return Env().Undefined();
6464
}

test/unit/proxy-run-test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
5656
} catch (err) {
5757
assert.instanceOf(err, Error)
5858
assert.equal(err.message, "Back-end socket must be bound or connected")
59+
assert.equal(err.code, "EINVAL")
60+
assert.typeOf(err.errno, "number")
5961
}
6062
})
6163

@@ -70,6 +72,8 @@ for (const proto of testProtos("tcp", "ipc", "inproc")) {
7072
} catch (err) {
7173
assert.instanceOf(err, Error)
7274
assert.equal(err.message, "Back-end socket must be bound or connected")
75+
assert.equal(err.code, "EINVAL")
76+
assert.typeOf(err.errno, "number")
7377
}
7478
})
7579
})

0 commit comments

Comments
 (0)