mirror of
https://github.com/denoland/deno.git
synced 2025-09-21 18:10:02 +00:00
dx: descriptive permission errors (#3808)
Before: ``` ▶ target/debug/deno https://deno.land/std/examples/echo_server.ts error: Uncaught PermissionDenied: run again with the --allow-net flag ► $deno$/dispatch_json.ts:40:11 at DenoError ($deno$/errors.ts:20:5) at unwrapResponse ($deno$/dispatch_json.ts:40:11) at sendSync ($deno$/dispatch_json.ts:67:10) at listen ($deno$/net.ts:170:15) at https://deno.land/std/examples/echo_server.ts:4:23 ``` ``` ▶ target/debug/deno --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd error: Uncaught PermissionDenied: run again with the --allow-read flag ► $deno$/dispatch_json.ts:40:11 at DenoError ($deno$/errors.ts:20:5) at unwrapResponse ($deno$/dispatch_json.ts:40:11) at sendAsync ($deno$/dispatch_json.ts:91:10) ``` After: ``` ▶ target/debug/deno https://deno.land/std/examples/echo_server.ts error: Uncaught PermissionDenied: network access to "0.0.0.0:8080", run again with the --allow-net flag ► $deno$/dispatch_json.ts:40:11 at DenoError ($deno$/errors.ts:20:5) at unwrapResponse ($deno$/dispatch_json.ts:40:11) at sendSync ($deno$/dispatch_json.ts:67:10) at listen ($deno$/net.ts:170:15) at https://deno.land/std/examples/echo_server.ts:4:23 ``` ``` ▶ target/debug/deno --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag ► $deno$/dispatch_json.ts:40:11 at DenoError ($deno$/errors.ts:20:5) at unwrapResponse ($deno$/dispatch_json.ts:40:11) at sendAsync ($deno$/dispatch_json.ts:91:10) ```
This commit is contained in:
parent
ac10d79d23
commit
f32c31a0eb
7 changed files with 25 additions and 28 deletions
|
@ -2,6 +2,7 @@
|
|||
import { test } from "../testing/mod.ts";
|
||||
import {
|
||||
assertEquals,
|
||||
assertStrContains,
|
||||
assertThrows,
|
||||
assertThrowsAsync
|
||||
} from "../testing/asserts.ts";
|
||||
|
@ -227,7 +228,7 @@ test(async function emptyDirPermission(): Promise<void> {
|
|||
|
||||
const output = await Deno.readAll(stdout);
|
||||
|
||||
assertEquals(new TextDecoder().decode(output), s.output);
|
||||
assertStrContains(new TextDecoder().decode(output), s.output);
|
||||
}
|
||||
} catch (err) {
|
||||
await Deno.remove(testfolder, { recursive: true });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue