summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal_binding/tcp_wrap.ts
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-09-10 20:12:24 +0200
committerGitHub <noreply@github.com>2024-09-10 11:12:24 -0700
commit7bfcb4dd10d31f5f9566c90a28449c0951f3a48e (patch)
treefca0dec6e98118418f1712c6e8451a04c7e89988 /ext/node/polyfills/internal_binding/tcp_wrap.ts
parentbe5419d479fcae16c8a07dec00ce11b532b7996a (diff)
feat(cli): use NotCapable error for permission errors (#25431)
Closes #7394 --------- Co-authored-by: snek <snek@deno.com>
Diffstat (limited to 'ext/node/polyfills/internal_binding/tcp_wrap.ts')
-rw-r--r--ext/node/polyfills/internal_binding/tcp_wrap.ts10
1 files changed, 2 insertions, 8 deletions
diff --git a/ext/node/polyfills/internal_binding/tcp_wrap.ts b/ext/node/polyfills/internal_binding/tcp_wrap.ts
index 4b57a7e1e..973a1d1c0 100644
--- a/ext/node/polyfills/internal_binding/tcp_wrap.ts
+++ b/ext/node/polyfills/internal_binding/tcp_wrap.ts
@@ -212,16 +212,10 @@ export class TCP extends ConnectionWrap {
try {
listener = Deno.listen(listenOptions);
} catch (e) {
- if (e instanceof Deno.errors.AddrInUse) {
- return codeMap.get("EADDRINUSE")!;
- } else if (e instanceof Deno.errors.AddrNotAvailable) {
- return codeMap.get("EADDRNOTAVAIL")!;
- } else if (e instanceof Deno.errors.PermissionDenied) {
+ if (e instanceof Deno.errors.NotCapable) {
throw e;
}
-
- // TODO(cmorten): map errors to appropriate error codes.
- return codeMap.get("UNKNOWN")!;
+ return codeMap.get(e.code ?? "UNKNOWN") ?? codeMap.get("UNKNOWN")!;
}
const address = listener.addr as Deno.NetAddr;