Skip to content

Commit

Permalink
rename Deno.Err -> Deno.errors (denoland#4093)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Feb 24, 2020
1 parent db59705 commit e1687c0
Show file tree
Hide file tree
Showing 42 changed files with 137 additions and 137 deletions.
8 changes: 4 additions & 4 deletions cli/js/chmod_test.ts
Expand Up @@ -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 {
Expand All @@ -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");
});

Expand Down Expand Up @@ -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> {
Expand All @@ -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");
});
10 changes: 5 additions & 5 deletions cli/js/chown_test.ts
Expand Up @@ -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);
}
});

Expand All @@ -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);
}
}
);
Expand All @@ -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);
}
}
);
Expand All @@ -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 });
});
Expand All @@ -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 });
});
Expand Down
12 changes: 6 additions & 6 deletions cli/js/copy_file_test.ts
Expand Up @@ -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 {
Expand All @@ -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);
});
Expand All @@ -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);
});
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
});
Expand All @@ -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);
});
2 changes: 1 addition & 1 deletion cli/js/deno.ts
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions cli/js/dir_test.ts
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions cli/js/dispatch_minimal.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cli/js/errors.ts
@@ -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,
Expand Down Expand Up @@ -179,7 +179,7 @@ class Http extends Error {
}
}

export const Err = {
export const errors = {
NotFound: NotFound,
PermissionDenied: PermissionDenied,
ConnectionRefused: ConnectionRefused,
Expand Down
4 changes: 2 additions & 2 deletions cli/js/fetch_test.ts
Expand Up @@ -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");
});

Expand All @@ -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");
});

Expand Down
6 changes: 3 additions & 3 deletions cli/js/files_test.ts
Expand Up @@ -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");
}
});
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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");
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/js/fs_events_test.ts
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion cli/js/lib.deno.ns.d.ts
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions cli/js/link_test.ts
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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");
});

Expand All @@ -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");
});

Expand Down
12 changes: 6 additions & 6 deletions cli/js/make_temp_test.ts
Expand Up @@ -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 {
Expand All @@ -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");
});

Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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");
});

Expand All @@ -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);
});
4 changes: 2 additions & 2 deletions cli/js/mkdir_test.ts
Expand Up @@ -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");
});

Expand All @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions cli/js/net_test.ts
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit e1687c0

Please sign in to comment.