From 7bfcb4dd10d31f5f9566c90a28449c0951f3a48e Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 10 Sep 2024 20:12:24 +0200 Subject: feat(cli): use NotCapable error for permission errors (#25431) Closes #7394 --------- Co-authored-by: snek --- tests/unit_node/fs_test.ts | 2 +- tests/unit_node/net_test.ts | 2 +- tests/unit_node/os_test.ts | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/unit_node') diff --git a/tests/unit_node/fs_test.ts b/tests/unit_node/fs_test.ts index c94a2447e..b1f7c53e8 100644 --- a/tests/unit_node/fs_test.ts +++ b/tests/unit_node/fs_test.ts @@ -88,7 +88,7 @@ Deno.test( () => { assertThrows(() => { existsSync("tests/testdata/assets/fixture.json"); - }, Deno.errors.PermissionDenied); + }, Deno.errors.NotCapable); }, ); diff --git a/tests/unit_node/net_test.ts b/tests/unit_node/net_test.ts index 8196874f3..83d751866 100644 --- a/tests/unit_node/net_test.ts +++ b/tests/unit_node/net_test.ts @@ -113,7 +113,7 @@ Deno.test({ const s = new net.Server(); s.listen(3000); } catch (e) { - assert(e instanceof Deno.errors.PermissionDenied); + assert(e instanceof Deno.errors.NotCapable); } }, }); diff --git a/tests/unit_node/os_test.ts b/tests/unit_node/os_test.ts index a75b66807..78636e755 100644 --- a/tests/unit_node/os_test.ts +++ b/tests/unit_node/os_test.ts @@ -8,6 +8,7 @@ import { assertNotEquals, assertThrows, } from "@std/assert"; +import console from "node:console"; Deno.test({ name: "build architecture is a string", @@ -298,7 +299,14 @@ Deno.test({ args: ["eval", "while (true) { console.log('foo') }"], }).spawn(); assertThrows( - () => os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH), + () => { + try { + os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH); + } catch (err) { + console.error(err); + throw err; + } + }, Deno.errors.PermissionDenied, ); os.getPriority(child.pid); -- cgit v1.2.3