1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 23:34:47 -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) {
err = e;
}
assert(err instanceof Deno.Err.NotFound);
assert(err instanceof Deno.errors.NotFound);
});
testPerm({ write: false }, function chmodSyncPerm(): void {
@ -70,7 +70,7 @@ testPerm({ write: false }, function chmodSyncPerm(): void {
} catch (e) {
err = e;
}
assert(err instanceof Deno.Err.PermissionDenied);
assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});
@ -133,7 +133,7 @@ testPerm({ write: true }, async function chmodFailure(): Promise<void> {
} catch (e) {
err = e;
}
assert(err instanceof Deno.Err.NotFound);
assert(err instanceof Deno.errors.NotFound);
});
testPerm({ write: false }, async function chmodPerm(): Promise<void> {
@ -143,6 +143,6 @@ testPerm({ write: false }, async function chmodPerm(): Promise<void> {
} catch (e) {
err = e;
}
assert(err instanceof Deno.Err.PermissionDenied);
assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
});

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
import * as util from "./util.ts";
import { core } from "./core.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>>();
// 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));
err = { kind, message };
} else if (ui8.length != 12) {
throw new Err.InvalidData("BadMessage");
throw new errors.InvalidData("BadMessage");
}
return {

View file

@ -1,6 +1,6 @@
// 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!
export enum ErrorKind {
NotFound = 1,
@ -179,7 +179,7 @@ class Http extends Error {
}
}
export const Err = {
export const errors = {
NotFound: NotFound,
PermissionDenied: PermissionDenied,
ConnectionRefused: ConnectionRefused,

View file

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

View file

@ -79,7 +79,7 @@ testPerm({ write: false }, async function writePermFailure(): Promise<void> {
err = e;
}
assert(!!err);
assert(err instanceof Deno.Err.PermissionDenied);
assert(err instanceof Deno.errors.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");
} catch (e) {
caughtError = true;
assert(e instanceof Deno.Err.PermissionDenied);
assert(e instanceof Deno.errors.PermissionDenied);
}
assert(caughtError);
});
@ -208,7 +208,7 @@ testPerm(
err = e;
}
assert(!!err);
assert(err instanceof Deno.Err.PermissionDenied);
assert(err instanceof Deno.errors.PermissionDenied);
assertEquals(err.name, "PermissionDenied");
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -50,7 +50,7 @@
// abortAlgorithm = (): void => {
// // TODO this should be a DOMException,
// // 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>> = [];
// if (preventAbort === false) {
// actions.push(() => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -235,7 +235,7 @@ testWalk(
async function nonexistentRoot(): Promise<void> {
await assertThrowsAsync(async () => {
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> {
if (e instanceof Deno.Err.NotFound) {
if (e instanceof Deno.errors.NotFound) {
return {
status: 404,
body: encoder.encode("Not found")

View file

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

View file

@ -24,7 +24,7 @@ test({
() => {
process.chdir("non-existent-directory-name");
},
Deno.Err.NotFound,
Deno.errors.NotFound,
"file"
// 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

View file

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