diff options
author | Luca Casonato <hello@lcas.dev> | 2024-09-10 20:12:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-10 11:12:24 -0700 |
commit | 7bfcb4dd10d31f5f9566c90a28449c0951f3a48e (patch) | |
tree | fca0dec6e98118418f1712c6e8451a04c7e89988 /ext/node/polyfills/internal_binding/tcp_wrap.ts | |
parent | be5419d479fcae16c8a07dec00ce11b532b7996a (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.ts | 10 |
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; |