1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/node): implement uv.errname (#20785)

Fixes https://github.com/denoland/deno/issues/20617
This commit is contained in:
Divy Srivastava 2023-10-05 23:57:20 +05:30 committed by GitHub
parent 176bf9ba5f
commit ab3c9d41e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -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");
},
});

View file

@ -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})`;
}