1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-10 08:09:06 -05:00

rename Deno.Err -> Deno.errors (#4093)

This commit is contained in:
Bartek Iwańczuk 2020-02-24 15:48:35 -05:00 committed by GitHub
parent db59705595
commit e1687c0a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 137 additions and 137 deletions

View file

@ -60,7 +60,7 @@ testPerm({ write: true }, function chmodSyncFailure(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: false }, function chmodSyncPerm(): void { testPerm({ write: false }, function chmodSyncPerm(): void {
@ -70,7 +70,7 @@ testPerm({ write: false }, function chmodSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -133,7 +133,7 @@ testPerm({ write: true }, async function chmodFailure(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: false }, async function chmodPerm(): Promise<void> { testPerm({ write: false }, async function chmodPerm(): Promise<void> {
@ -143,6 +143,6 @@ testPerm({ write: false }, async function chmodPerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -31,7 +31,7 @@ if (Deno.build.os !== "win") {
try { try {
await Deno.chown(filePath, 1000, 1000); await Deno.chown(filePath, 1000, 1000);
} catch (e) { } catch (e) {
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
}); });
@ -44,7 +44,7 @@ if (Deno.build.os !== "win") {
try { try {
Deno.chownSync(filePath, uid, gid); Deno.chownSync(filePath, uid, gid);
} catch (e) { } catch (e) {
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
} }
); );
@ -58,7 +58,7 @@ if (Deno.build.os !== "win") {
try { try {
await Deno.chown(filePath, uid, gid); await Deno.chown(filePath, uid, gid);
} catch (e) { } catch (e) {
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
} }
); );
@ -74,7 +74,7 @@ if (Deno.build.os !== "win") {
// try changing the file's owner to root // try changing the file's owner to root
Deno.chownSync(filePath, 0, 0); Deno.chownSync(filePath, 0, 0);
} catch (e) { } catch (e) {
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
Deno.removeSync(dirPath, { recursive: true }); Deno.removeSync(dirPath, { recursive: true });
}); });
@ -92,7 +92,7 @@ if (Deno.build.os !== "win") {
// try changing the file's owner to root // try changing the file's owner to root
await Deno.chown(filePath, 0, 0); await Deno.chown(filePath, 0, 0);
} catch (e) { } catch (e) {
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
await Deno.remove(dirPath, { recursive: true }); await Deno.remove(dirPath, { recursive: true });
}); });

View file

@ -43,7 +43,7 @@ testPerm({ write: true, read: true }, function copyFileSyncFailure(): void {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: true, read: false }, function copyFileSyncPerm1(): void { testPerm({ write: true, read: false }, function copyFileSyncPerm1(): void {
@ -52,7 +52,7 @@ testPerm({ write: true, read: false }, function copyFileSyncPerm1(): void {
Deno.copyFileSync("/from.txt", "/to.txt"); Deno.copyFileSync("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -63,7 +63,7 @@ testPerm({ write: false, read: true }, function copyFileSyncPerm2(): void {
Deno.copyFileSync("/from.txt", "/to.txt"); Deno.copyFileSync("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -110,7 +110,7 @@ testPerm({ read: true, write: true }, async function copyFileFailure(): Promise<
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm( testPerm(
@ -138,7 +138,7 @@ testPerm({ read: false, write: true }, async function copyFilePerm1(): Promise<
await Deno.copyFile("/from.txt", "/to.txt"); await Deno.copyFile("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -151,7 +151,7 @@ testPerm({ read: true, write: false }, async function copyFilePerm2(): Promise<
await Deno.copyFile("/from.txt", "/to.txt"); await Deno.copyFile("/from.txt", "/to.txt");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -22,7 +22,7 @@ export {
} from "./diagnostics.ts"; } from "./diagnostics.ts";
export { chdir, cwd } from "./dir.ts"; export { chdir, cwd } from "./dir.ts";
export { applySourceMap } from "./error_stack.ts"; export { applySourceMap } from "./error_stack.ts";
export { Err } from "./errors.ts"; export { errors } from "./errors.ts";
export { FileInfo } from "./file_info.ts"; export { FileInfo } from "./file_info.ts";
export { export {
File, File,

View file

@ -29,7 +29,7 @@ testPerm({ write: true }, function dirCwdError(): void {
Deno.cwd(); Deno.cwd();
throw Error("current directory removed, should throw error"); throw Error("current directory removed, should throw error");
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
console.log(err.name === "NotFound"); console.log(err.name === "NotFound");
} else { } else {
throw Error("raised different exception"); throw Error("raised different exception");
@ -45,7 +45,7 @@ testPerm({ write: true }, function dirChdirError(): void {
Deno.chdir(path); Deno.chdir(path);
throw Error("directory not available, should throw error"); throw Error("directory not available, should throw error");
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
console.log(err.name === "NotFound"); console.log(err.name === "NotFound");
} else { } else {
throw Error("raised different exception"); throw Error("raised different exception");

View file

@ -2,7 +2,7 @@
import * as util from "./util.ts"; import * as util from "./util.ts";
import { core } from "./core.ts"; import { core } from "./core.ts";
import { TextDecoder } from "./text_encoding.ts"; import { TextDecoder } from "./text_encoding.ts";
import { Err, ErrorKind, constructError } from "./errors.ts"; import { errors, ErrorKind, constructError } from "./errors.ts";
const promiseTableMin = new Map<number, util.Resolvable<RecordMinimal>>(); const promiseTableMin = new Map<number, util.Resolvable<RecordMinimal>>();
// Note it's important that promiseId starts at 1 instead of 0, because sync // Note it's important that promiseId starts at 1 instead of 0, because sync
@ -43,7 +43,7 @@ export function recordFromBufMinimal(ui8: Uint8Array): RecordMinimal {
const message = decoder.decode(ui8.slice(12)); const message = decoder.decode(ui8.slice(12));
err = { kind, message }; err = { kind, message };
} else if (ui8.length != 12) { } else if (ui8.length != 12) {
throw new Err.InvalidData("BadMessage"); throw new errors.InvalidData("BadMessage");
} }
return { return {

View file

@ -1,6 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// Warning! The values in this enum are duplicated in cli/msg.rs // Warning! The values in this enum are duplicated in cli/op_error.rs
// Update carefully! // Update carefully!
export enum ErrorKind { export enum ErrorKind {
NotFound = 1, NotFound = 1,
@ -179,7 +179,7 @@ class Http extends Error {
} }
} }
export const Err = { export const errors = {
NotFound: NotFound, NotFound: NotFound,
PermissionDenied: PermissionDenied, PermissionDenied: PermissionDenied,
ConnectionRefused: ConnectionRefused, ConnectionRefused: ConnectionRefused,

View file

@ -27,7 +27,7 @@ testPerm({ net: true }, async function fetchConnectionError(): Promise<void> {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.Http); assert(err instanceof Deno.errors.Http);
assertStrContains(err.message, "error trying to connect"); assertStrContains(err.message, "error trying to connect");
}); });
@ -44,7 +44,7 @@ test(async function fetchPerm(): Promise<void> {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -79,7 +79,7 @@ testPerm({ write: false }, async function writePermFailure(): Promise<void> {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
}); });
@ -136,7 +136,7 @@ testPerm({ read: false }, async function readPermFailure(): Promise<void> {
await Deno.open("cli/tests/fixture.json", "r"); await Deno.open("cli/tests/fixture.json", "r");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -208,7 +208,7 @@ testPerm(
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
} }

View file

@ -8,7 +8,7 @@ testPerm({ read: false }, function fsEventsPermissions() {
try { try {
Deno.fsEvents("."); Deno.fsEvents(".");
} catch (err) { } catch (err) {
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
thrown = true; thrown = true;
} }
assert(thrown); assert(thrown);

View file

@ -1217,7 +1217,7 @@ declare namespace Deno {
export function applySourceMap(location: Location): Location; export function applySourceMap(location: Location): Location;
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
namespace Err { namespace errors {
class NotFound extends Error { class NotFound extends Error {
constructor(msg: string); constructor(msg: string);
} }

View file

@ -43,7 +43,7 @@ testPerm({ read: true, write: true }, function linkSyncExists(): void {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.AlreadyExists); assert(err instanceof Deno.errors.AlreadyExists);
}); });
testPerm({ read: true, write: true }, function linkSyncNotFound(): void { testPerm({ read: true, write: true }, function linkSyncNotFound(): void {
@ -58,7 +58,7 @@ testPerm({ read: true, write: true }, function linkSyncNotFound(): void {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ read: false, write: true }, function linkSyncReadPerm(): void { testPerm({ read: false, write: true }, function linkSyncReadPerm(): void {
@ -68,7 +68,7 @@ testPerm({ read: false, write: true }, function linkSyncReadPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -79,7 +79,7 @@ testPerm({ read: true, write: false }, function linkSyncWritePerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -23,7 +23,7 @@ testPerm({ write: true }, function makeTempDirSyncSuccess(): void {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
test(function makeTempDirSyncPerm(): void { test(function makeTempDirSyncPerm(): void {
@ -34,7 +34,7 @@ test(function makeTempDirSyncPerm(): void {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -60,7 +60,7 @@ testPerm({ write: true }, async function makeTempDirSuccess(): Promise<void> {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: true }, function makeTempFileSyncSuccess(): void { testPerm({ write: true }, function makeTempFileSyncSuccess(): void {
@ -86,7 +86,7 @@ testPerm({ write: true }, function makeTempFileSyncSuccess(): void {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
test(function makeTempFileSyncPerm(): void { test(function makeTempFileSyncPerm(): void {
@ -97,7 +97,7 @@ test(function makeTempFileSyncPerm(): void {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -124,5 +124,5 @@ testPerm({ write: true }, async function makeTempFileSuccess(): Promise<void> {
} catch (err_) { } catch (err_) {
err = err_; err = err_;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });

View file

@ -25,7 +25,7 @@ testPerm({ write: false }, function mkdirSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -45,7 +45,7 @@ testPerm({ write: true }, function mkdirErrIfExists(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.AlreadyExists); assert(err instanceof Deno.errors.AlreadyExists);
}); });
testPerm({ read: true, write: true }, function mkdirSyncRecursive(): void { testPerm({ read: true, write: true }, function mkdirSyncRecursive(): void {

View file

@ -223,7 +223,7 @@ testPerm({ net: true }, async function netDoubleCloseRead() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.NotConnected); assert(err instanceof Deno.errors.NotConnected);
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();
@ -257,7 +257,7 @@ testPerm({ net: true }, async function netCloseWriteSuccess() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.BrokenPipe); assert(err instanceof Deno.errors.BrokenPipe);
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();
@ -283,7 +283,7 @@ testPerm({ net: true }, async function netDoubleCloseWrite() {
err = e; err = e;
} }
assert(!!err); assert(!!err);
assert(err instanceof Deno.Err.NotConnected); assert(err instanceof Deno.errors.NotConnected);
closeDeferred.resolve(); closeDeferred.resolve();
listener.close(); listener.close();
conn.close(); conn.close();

View file

@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import * as dispatch from "./dispatch.ts"; import * as dispatch from "./dispatch.ts";
import { sendSync } from "./dispatch_json.ts"; import { sendSync } from "./dispatch_json.ts";
import { Err } from "./errors.ts"; import { errors } from "./errors.ts";
import * as util from "./util.ts"; import * as util from "./util.ts";
/** Check if running in terminal. /** Check if running in terminal.
@ -210,7 +210,7 @@ export function dir(kind: DirKind): string | null {
try { try {
return sendSync(dispatch.OP_GET_DIR, { kind }); return sendSync(dispatch.OP_GET_DIR, { kind });
} catch (error) { } catch (error) {
if (error instanceof Err.PermissionDenied) { if (error instanceof errors.PermissionDenied) {
throw error; throw error;
} }
return null; return null;

View file

@ -31,7 +31,7 @@ test(function envPermissionDenied1(): void {
err = e; err = e;
} }
assertNotEquals(err, undefined); assertNotEquals(err, undefined);
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -43,7 +43,7 @@ test(function envPermissionDenied2(): void {
err = e; err = e;
} }
assertNotEquals(err, undefined); assertNotEquals(err, undefined);
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -262,7 +262,7 @@ testPerm({ env: true }, function getDir(): void {
testPerm({}, function getDirWithoutPermission(): void { testPerm({}, function getDirWithoutPermission(): void {
assertThrows( assertThrows(
() => Deno.dir("home"), () => Deno.dir("home"),
Deno.Err.PermissionDenied, Deno.errors.PermissionDenied,
`run again with the --allow-env flag` `run again with the --allow-env flag`
); );
}); });
@ -277,7 +277,7 @@ testPerm({ env: false }, function execPathPerm(): void {
Deno.execPath(); Deno.execPath();
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
@ -294,7 +294,7 @@ testPerm({ env: false }, function loadavgPerm(): void {
Deno.loadavg(); Deno.loadavg();
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);
@ -310,7 +310,7 @@ testPerm({ env: false }, function hostnamePerm(): void {
Deno.hostname(); Deno.hostname();
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
} }
assert(caughtError); assert(caughtError);

View file

@ -14,7 +14,7 @@ test(function runPermissions(): void {
Deno.run({ args: ["python", "-c", "print('hello world')"] }); Deno.run({ args: ["python", "-c", "print('hello world')"] });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -68,7 +68,7 @@ testPerm({ run: true }, function runNotFound(): void {
error = e; error = e;
} }
assert(error !== undefined); assert(error !== undefined);
assert(error instanceof Deno.Err.NotFound); assert(error instanceof Deno.errors.NotFound);
}); });
testPerm( testPerm(
@ -321,7 +321,7 @@ if (Deno.build.os !== "win") {
Deno.kill(Deno.pid, Deno.Signal.SIGCONT); Deno.kill(Deno.pid, Deno.Signal.SIGCONT);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -32,7 +32,7 @@ testPerm({ read: false }, function readDirSyncPerm(): void {
Deno.readDirSync("tests/"); Deno.readDirSync("tests/");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -59,7 +59,7 @@ testPerm({ read: true }, function readDirSyncNotFound(): void {
src = Deno.readDirSync("bad_dir_name"); src = Deno.readDirSync("bad_dir_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
assertEquals(src, undefined); assertEquals(src, undefined);
@ -76,7 +76,7 @@ testPerm({ read: false }, async function readDirPerm(): Promise<void> {
await Deno.readDir("tests/"); await Deno.readDir("tests/");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -16,7 +16,7 @@ testPerm({ read: false }, function readFileSyncPerm(): void {
Deno.readFileSync("cli/tests/fixture.json"); Deno.readFileSync("cli/tests/fixture.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -28,7 +28,7 @@ testPerm({ read: true }, function readFileSyncNotFound(): void {
data = Deno.readFileSync("bad_filename"); data = Deno.readFileSync("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
assert(data === undefined); assert(data === undefined);
@ -49,7 +49,7 @@ testPerm({ read: false }, async function readFilePerm(): Promise<void> {
await Deno.readFile("cli/tests/fixture.json"); await Deno.readFile("cli/tests/fixture.json");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -21,7 +21,7 @@ testPerm({ read: false }, async function readlinkSyncPerm(): Promise<void> {
Deno.readlinkSync("/symlink"); Deno.readlinkSync("/symlink");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -33,7 +33,7 @@ testPerm({ read: true }, function readlinkSyncNotFound(): void {
data = Deno.readlinkSync("bad_filename"); data = Deno.readlinkSync("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
assertEquals(data, undefined); assertEquals(data, undefined);
@ -61,7 +61,7 @@ testPerm({ read: false }, async function readlinkPerm(): Promise<void> {
await Deno.readlink("/symlink"); await Deno.readlink("/symlink");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -31,7 +31,7 @@ testPerm({ read: false }, function realpathSyncPerm(): void {
Deno.realpathSync("some_file"); Deno.realpathSync("some_file");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -42,7 +42,7 @@ testPerm({ read: true }, function realpathSyncNotFound(): void {
Deno.realpathSync("bad_filename"); Deno.realpathSync("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
}); });
@ -80,7 +80,7 @@ testPerm({ read: false }, async function realpathPerm(): Promise<void> {
await Deno.realpath("some_file"); await Deno.realpath("some_file");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -91,7 +91,7 @@ testPerm({ read: true }, async function realpathNotFound(): Promise<void> {
await Deno.realpath("bad_filename"); await Deno.realpath("bad_filename");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -18,7 +18,7 @@ testPerm({ write: true, read: true }, function removeSyncDirSuccess(): void {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: true, read: true }, function removeSyncFileSuccess(): void { testPerm({ write: true, read: true }, function removeSyncFileSuccess(): void {
@ -38,7 +38,7 @@ testPerm({ write: true, read: true }, function removeSyncFileSuccess(): void {
err = e; err = e;
} }
// File is gone // File is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: true, read: true }, function removeSyncFail(): void { testPerm({ write: true, read: true }, function removeSyncFail(): void {
@ -67,7 +67,7 @@ testPerm({ write: true, read: true }, function removeSyncFail(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm( testPerm(
@ -93,7 +93,7 @@ testPerm(
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
} }
); );
@ -127,7 +127,7 @@ testPerm(
err = e; err = e;
} }
Deno.removeSync(filePath); Deno.removeSync(filePath);
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
} }
); );
@ -139,7 +139,7 @@ testPerm({ write: false }, function removeSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -158,7 +158,7 @@ testPerm({ write: true, read: true }, function removeAllSyncDirSuccess(): void {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
// REMOVE NON-EMPTY DIRECTORY // REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir"; path = Deno.makeTempDirSync() + "/dir/subdir";
@ -177,7 +177,7 @@ testPerm({ write: true, read: true }, function removeAllSyncDirSuccess(): void {
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm( testPerm(
@ -199,7 +199,7 @@ testPerm(
err = e; err = e;
} }
// File is gone // File is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -212,7 +212,7 @@ testPerm({ write: true }, function removeAllSyncFail(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: false }, function removeAllSyncPerm(): void { testPerm({ write: false }, function removeAllSyncPerm(): void {
@ -222,7 +222,7 @@ testPerm({ write: false }, function removeAllSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -245,7 +245,7 @@ testPerm(
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -268,7 +268,7 @@ testPerm(
err = e; err = e;
} }
// File is gone // File is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -299,7 +299,7 @@ testPerm({ write: true, read: true }, async function removeFail(): Promise<
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm( testPerm(
@ -325,7 +325,7 @@ testPerm(
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
} }
); );
@ -359,7 +359,7 @@ testPerm(
err = e; err = e;
} }
Deno.removeSync(filePath); Deno.removeSync(filePath);
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
} }
); );
@ -371,7 +371,7 @@ testPerm({ write: false }, async function removePerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -392,7 +392,7 @@ testPerm(
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
// REMOVE NON-EMPTY DIRECTORY // REMOVE NON-EMPTY DIRECTORY
path = Deno.makeTempDirSync() + "/dir/subdir"; path = Deno.makeTempDirSync() + "/dir/subdir";
@ -411,7 +411,7 @@ testPerm(
err = e; err = e;
} }
// Directory is gone // Directory is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -434,7 +434,7 @@ testPerm(
err = e; err = e;
} }
// File is gone // File is gone
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -447,7 +447,7 @@ testPerm({ write: true }, async function removeAllFail(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
}); });
testPerm({ write: false }, async function removeAllPerm(): Promise<void> { testPerm({ write: false }, async function removeAllPerm(): Promise<void> {
@ -457,6 +457,6 @@ testPerm({ write: false }, async function removeAllPerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -17,7 +17,7 @@ testPerm({ read: true, write: true }, function renameSyncSuccess(): void {
oldPathInfo = Deno.statSync(oldpath); oldPathInfo = Deno.statSync(oldpath);
} catch (e) { } catch (e) {
caughtErr = true; caughtErr = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtErr); assert(caughtErr);
assertEquals(oldPathInfo, undefined); assertEquals(oldPathInfo, undefined);
@ -32,7 +32,7 @@ testPerm({ read: false, write: true }, function renameSyncReadPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -45,7 +45,7 @@ testPerm({ read: true, write: false }, function renameSyncWritePerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -67,7 +67,7 @@ testPerm({ read: true, write: true }, async function renameSuccess(): Promise<
oldPathInfo = Deno.statSync(oldpath); oldPathInfo = Deno.statSync(oldpath);
} catch (e) { } catch (e) {
caughtErr = true; caughtErr = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtErr); assert(caughtErr);
assertEquals(oldPathInfo, undefined); assertEquals(oldPathInfo, undefined);

View file

@ -23,7 +23,7 @@ testPerm({ read: false }, async function statSyncPerm(): Promise<void> {
Deno.statSync("README.md"); Deno.statSync("README.md");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -36,7 +36,7 @@ testPerm({ read: true }, async function statSyncNotFound(): Promise<void> {
badInfo = Deno.statSync("bad_file_name"); badInfo = Deno.statSync("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
@ -63,7 +63,7 @@ testPerm({ read: false }, async function lstatSyncPerm(): Promise<void> {
Deno.lstatSync("README.md"); Deno.lstatSync("README.md");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -76,7 +76,7 @@ testPerm({ read: true }, async function lstatSyncNotFound(): Promise<void> {
badInfo = Deno.lstatSync("bad_file_name"); badInfo = Deno.lstatSync("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
@ -103,7 +103,7 @@ testPerm({ read: false }, async function statPerm(): Promise<void> {
await Deno.stat("README.md"); await Deno.stat("README.md");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -116,7 +116,7 @@ testPerm({ read: true }, async function statNotFound(): Promise<void> {
badInfo = await Deno.stat("bad_file_name"); badInfo = await Deno.stat("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
@ -143,7 +143,7 @@ testPerm({ read: false }, async function lstatPerm(): Promise<void> {
await Deno.lstat("README.md"); await Deno.lstat("README.md");
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -156,7 +156,7 @@ testPerm({ read: true }, async function lstatNotFound(): Promise<void> {
badInfo = await Deno.lstat("bad_file_name"); badInfo = await Deno.lstat("bad_file_name");
} catch (err) { } catch (err) {
caughtError = true; caughtError = true;
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);

View file

@ -50,7 +50,7 @@
// abortAlgorithm = (): void => { // abortAlgorithm = (): void => {
// // TODO this should be a DOMException, // // TODO this should be a DOMException,
// // https://github.com/stardazed/sd-streams/blob/master/packages/streams/src/pipe-to.ts#L38 // // https://github.com/stardazed/sd-streams/blob/master/packages/streams/src/pipe-to.ts#L38
// const error = new Err.Aborted("Aborted"); // const error = new errors.Aborted("Aborted");
// const actions: Array<() => Promise<void>> = []; // const actions: Array<() => Promise<void>> = [];
// if (preventAbort === false) { // if (preventAbort === false) {
// actions.push(() => { // actions.push(() => {

View file

@ -31,7 +31,7 @@ test(function symlinkSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -13,7 +13,7 @@ test(async function connectTLSNoPerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -28,7 +28,7 @@ test(async function connectTLSCertFileNoReadPerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -51,7 +51,7 @@ testPerm(
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
try { try {
Deno.listenTLS({ Deno.listenTLS({
@ -61,7 +61,7 @@ testPerm(
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.NotFound); assert(err instanceof Deno.errors.NotFound);
} }
); );
@ -77,7 +77,7 @@ testPerm({ net: true }, async function listenTLSNoReadPerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -58,7 +58,7 @@ testPerm({ write: false }, function truncateSyncPerm(): void {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });
@ -69,6 +69,6 @@ testPerm({ write: false }, async function truncatePerm(): Promise<void> {
} catch (e) { } catch (e) {
err = e; err = e;
} }
assert(err instanceof Deno.Err.PermissionDenied); assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied"); assertEquals(err.name, "PermissionDenied");
}); });

View file

@ -78,7 +78,7 @@ testPerm({ read: true, write: true }, function utimeSyncNotFound(): void {
Deno.utimeSync("/baddir", atime, mtime); Deno.utimeSync("/baddir", atime, mtime);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
}); });
@ -92,7 +92,7 @@ testPerm({ read: true, write: false }, function utimeSyncPerm(): void {
Deno.utimeSync("/some_dir", atime, mtime); Deno.utimeSync("/some_dir", atime, mtime);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -157,7 +157,7 @@ testPerm({ read: true, write: true }, async function utimeNotFound(): Promise<
await Deno.utime("/baddir", atime, mtime); await Deno.utime("/baddir", atime, mtime);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
}); });
@ -173,7 +173,7 @@ testPerm({ read: true, write: false }, async function utimeSyncPerm(): Promise<
await Deno.utime("/some_dir", atime, mtime); await Deno.utime("/some_dir", atime, mtime);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });

View file

@ -22,7 +22,7 @@ testPerm({ write: true }, function writeFileSyncFail(): void {
Deno.writeFileSync(filename, data); Deno.writeFileSync(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
}); });
@ -37,7 +37,7 @@ testPerm({ write: false }, function writeFileSyncPerm(): void {
Deno.writeFileSync(filename, data); Deno.writeFileSync(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -64,7 +64,7 @@ testPerm({ read: true, write: true }, function writeFileSyncCreate(): void {
Deno.writeFileSync(filename, data, { create: false }); Deno.writeFileSync(filename, data, { create: false });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
@ -125,7 +125,7 @@ testPerm(
await Deno.writeFile(filename, data); await Deno.writeFile(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);
} }
@ -143,7 +143,7 @@ testPerm({ read: true, write: false }, async function writeFilePerm(): Promise<
await Deno.writeFile(filename, data); await Deno.writeFile(filename, data);
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied); assert(e instanceof Deno.errors.PermissionDenied);
} }
assert(caughtError); assert(caughtError);
}); });
@ -175,7 +175,7 @@ testPerm({ read: true, write: true }, async function writeFileCreate(): Promise<
await Deno.writeFile(filename, data, { create: false }); await Deno.writeFile(filename, data, { create: false });
} catch (e) { } catch (e) {
caughtError = true; caughtError = true;
assert(e instanceof Deno.Err.NotFound); assert(e instanceof Deno.errors.NotFound);
} }
assert(caughtError); assert(caughtError);

View file

@ -29,7 +29,7 @@ async function ensureValidCopy(
try { try {
destStat = await Deno.lstat(dest); destStat = await Deno.lstat(dest);
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
return; return;
} }
throw err; throw err;
@ -57,7 +57,7 @@ function ensureValidCopySync(
try { try {
destStat = Deno.lstatSync(dest); destStat = Deno.lstatSync(dest);
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
return; return;
} }
throw err; throw err;

View file

@ -20,7 +20,7 @@ export async function emptyDir(dir: string): Promise<void> {
} }
} }
} catch (err) { } catch (err) {
if (!(err instanceof Deno.Err.NotFound)) { if (!(err instanceof Deno.errors.NotFound)) {
throw err; throw err;
} }
@ -49,7 +49,7 @@ export function emptyDirSync(dir: string): void {
} }
} }
} catch (err) { } catch (err) {
if (!(err instanceof Deno.Err.NotFound)) { if (!(err instanceof Deno.errors.NotFound)) {
throw err; throw err;
} }
// if not exist. then create it // if not exist. then create it

View file

@ -16,7 +16,7 @@ export async function ensureDir(dir: string): Promise<void> {
); );
} }
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
// if dir not exists. then create it. // if dir not exists. then create it.
await mkdir(dir, { recursive: true }); await mkdir(dir, { recursive: true });
return; return;
@ -39,7 +39,7 @@ export function ensureDirSync(dir: string): void {
); );
} }
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
// if dir not exists. then create it. // if dir not exists. then create it.
mkdirSync(dir, { recursive: true }); mkdirSync(dir, { recursive: true });
return; return;

View file

@ -23,7 +23,7 @@ export async function ensureFile(filePath: string): Promise<void> {
} }
} catch (err) { } catch (err) {
// if file not exists // if file not exists
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
// ensure dir exists // ensure dir exists
await ensureDir(path.dirname(filePath)); await ensureDir(path.dirname(filePath));
// create file // create file
@ -54,7 +54,7 @@ export function ensureFileSync(filePath: string): void {
} }
} catch (err) { } catch (err) {
// if file not exists // if file not exists
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
// ensure dir exists // ensure dir exists
ensureDirSync(path.dirname(filePath)); ensureDirSync(path.dirname(filePath));
// create file // create file

View file

@ -7,7 +7,7 @@ export async function exists(filePath: string): Promise<boolean> {
return lstat(filePath) return lstat(filePath)
.then((): boolean => true) .then((): boolean => true)
.catch((err: Error): boolean => { .catch((err: Error): boolean => {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
return false; return false;
} }
@ -23,7 +23,7 @@ export function existsSync(filePath: string): boolean {
lstatSync(filePath); lstatSync(filePath);
return true; return true;
} catch (err) { } catch (err) {
if (err instanceof Deno.Err.NotFound) { if (err instanceof Deno.errors.NotFound) {
return false; return false;
} }
throw err; throw err;

View file

@ -43,7 +43,7 @@ function split(path: string): SplitPath {
} }
function throwUnlessNotFound(error: Error): void { function throwUnlessNotFound(error: Error): void {
if (!(error instanceof Deno.Err.NotFound)) { if (!(error instanceof Deno.errors.NotFound)) {
throw error; throw error;
} }
} }

View file

@ -235,7 +235,7 @@ testWalk(
async function nonexistentRoot(): Promise<void> { async function nonexistentRoot(): Promise<void> {
await assertThrowsAsync(async () => { await assertThrowsAsync(async () => {
await walkArray("nonexistent"); await walkArray("nonexistent");
}, Deno.Err.NotFound); }, Deno.errors.NotFound);
} }
); );

View file

@ -163,7 +163,7 @@ async function serveDir(
} }
async function serveFallback(req: ServerRequest, e: Error): Promise<Response> { async function serveFallback(req: ServerRequest, e: Error): Promise<Response> {
if (e instanceof Deno.Err.NotFound) { if (e instanceof Deno.errors.NotFound) {
return { return {
status: 404, status: 404,
body: encoder.encode("Not found") body: encoder.encode("Not found")

View file

@ -57,7 +57,7 @@ function stat(filename: string): StatResult {
if (statCache !== null) statCache.set(filename, result); if (statCache !== null) statCache.set(filename, result);
return result; return result;
} catch (e) { } catch (e) {
if (e instanceof Deno.Err.PermissionDenied) { if (e instanceof Deno.errors.PermissionDenied) {
throw new Error("CJS loader requires --allow-read."); throw new Error("CJS loader requires --allow-read.");
} }
return -1; return -1;

View file

@ -24,7 +24,7 @@ test({
() => { () => {
process.chdir("non-existent-directory-name"); process.chdir("non-existent-directory-name");
}, },
Deno.Err.NotFound, Deno.errors.NotFound,
"file" "file"
// On every OS Deno returns: "No such file" except for Windows, where it's: // On every OS Deno returns: "No such file" except for Windows, where it's:
// "The system cannot find the file specified. (os error 2)" so "file" is // "The system cannot find the file specified. (os error 2)" so "file" is

View file

@ -182,7 +182,7 @@ export async function runTestModules({
if (moduleCount == 0) { if (moduleCount == 0) {
const noneFoundMessage = "No matching test modules found."; const noneFoundMessage = "No matching test modules found.";
if (!allowNone) { if (!allowNone) {
throw new Deno.Err.NotFound(noneFoundMessage); throw new Deno.errors.NotFound(noneFoundMessage);
} else if (!disableLog) { } else if (!disableLog) {
console.log(noneFoundMessage); console.log(noneFoundMessage);
} }