1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -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 Bartek Iwańczuk
parent 0fb5d2e60c
commit e377c172e3
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 21 additions and 0 deletions

View file

@ -786,3 +786,16 @@ Deno.test({
worker.terminate(); 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_ENOENT = codeMap.get("ENOENT");
export const UV_ENOTSOCK = codeMap.get("ENOTSOCK")!; export const UV_ENOTSOCK = codeMap.get("ENOTSOCK")!;
export const UV_UNKNOWN = codeMap.get("UNKNOWN")!; 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})`;
}