summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit_node/process_test.ts13
-rw-r--r--ext/node/polyfills/internal_binding/uv.ts8
2 files changed, 21 insertions, 0 deletions
diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts
index bcb7a9767..78c5fcc97 100644
--- a/cli/tests/unit_node/process_test.ts
+++ b/cli/tests/unit_node/process_test.ts
@@ -786,3 +786,16 @@ Deno.test({
worker.terminate();
},
});
+
+Deno.test({
+ name: "process.binding('uv').errname",
+ ignore: Deno.build.os === "windows",
+ fn() {
+ // @ts-ignore: untyped internal binding, not actually supposed to be
+ // used by userland modules in Node.js
+ const uv = process.binding("uv");
+ assert(uv.errname);
+ assert(typeof uv.errname === "function");
+ assertEquals(uv.errname(-1), "EPERM");
+ },
+});
diff --git a/ext/node/polyfills/internal_binding/uv.ts b/ext/node/polyfills/internal_binding/uv.ts
index c08d44565..3cb145d28 100644
--- a/ext/node/polyfills/internal_binding/uv.ts
+++ b/ext/node/polyfills/internal_binding/uv.ts
@@ -531,3 +531,11 @@ export const UV_EINVAL = codeMap.get("EINVAL")!;
export const UV_ENOENT = codeMap.get("ENOENT");
export const UV_ENOTSOCK = codeMap.get("ENOTSOCK")!;
export const UV_UNKNOWN = codeMap.get("UNKNOWN")!;
+
+export function errname(errno: number): string {
+ const err = errorMap.get(errno);
+ if (err) {
+ return err[0];
+ }
+ return `UNKNOWN (${errno})`;
+}