mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 06:04:48 +00:00
clean up code in cli/js (#6611)
This commit is contained in:
parent
ab4c574f52
commit
158ae0bfe9
89 changed files with 395 additions and 354 deletions
|
@ -26,7 +26,11 @@ export enum ErrorKind {
|
|||
Busy = 23,
|
||||
}
|
||||
|
||||
export function getErrorClass(kind: ErrorKind): { new (msg: string): Error } {
|
||||
interface ErrorClass {
|
||||
new (msg: string): Error;
|
||||
}
|
||||
|
||||
export function getErrorClass(kind: ErrorKind): ErrorClass {
|
||||
switch (kind) {
|
||||
case ErrorKind.TypeError:
|
||||
return TypeError;
|
||||
|
@ -79,102 +83,119 @@ class NotFound extends Error {
|
|||
this.name = "NotFound";
|
||||
}
|
||||
}
|
||||
|
||||
class PermissionDenied extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "PermissionDenied";
|
||||
}
|
||||
}
|
||||
|
||||
class ConnectionRefused extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "ConnectionRefused";
|
||||
}
|
||||
}
|
||||
|
||||
class ConnectionReset extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "ConnectionReset";
|
||||
}
|
||||
}
|
||||
|
||||
class ConnectionAborted extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "ConnectionAborted";
|
||||
}
|
||||
}
|
||||
|
||||
class NotConnected extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "NotConnected";
|
||||
}
|
||||
}
|
||||
|
||||
class AddrInUse extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "AddrInUse";
|
||||
}
|
||||
}
|
||||
|
||||
class AddrNotAvailable extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "AddrNotAvailable";
|
||||
}
|
||||
}
|
||||
|
||||
class BrokenPipe extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "BrokenPipe";
|
||||
}
|
||||
}
|
||||
|
||||
class AlreadyExists extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "AlreadyExists";
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidData extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "InvalidData";
|
||||
}
|
||||
}
|
||||
|
||||
class TimedOut extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "TimedOut";
|
||||
}
|
||||
}
|
||||
|
||||
class Interrupted extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "Interrupted";
|
||||
}
|
||||
}
|
||||
|
||||
class WriteZero extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "WriteZero";
|
||||
}
|
||||
}
|
||||
|
||||
class UnexpectedEof extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "UnexpectedEof";
|
||||
}
|
||||
}
|
||||
|
||||
class BadResource extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "BadResource";
|
||||
}
|
||||
}
|
||||
|
||||
class Http extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
this.name = "Http";
|
||||
}
|
||||
}
|
||||
|
||||
class Busy extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
|
@ -183,22 +204,22 @@ class Busy extends Error {
|
|||
}
|
||||
|
||||
export const errors = {
|
||||
NotFound: NotFound,
|
||||
PermissionDenied: PermissionDenied,
|
||||
ConnectionRefused: ConnectionRefused,
|
||||
ConnectionReset: ConnectionReset,
|
||||
ConnectionAborted: ConnectionAborted,
|
||||
NotConnected: NotConnected,
|
||||
AddrInUse: AddrInUse,
|
||||
AddrNotAvailable: AddrNotAvailable,
|
||||
BrokenPipe: BrokenPipe,
|
||||
AlreadyExists: AlreadyExists,
|
||||
InvalidData: InvalidData,
|
||||
TimedOut: TimedOut,
|
||||
Interrupted: Interrupted,
|
||||
WriteZero: WriteZero,
|
||||
UnexpectedEof: UnexpectedEof,
|
||||
BadResource: BadResource,
|
||||
Http: Http,
|
||||
Busy: Busy,
|
||||
NotFound,
|
||||
PermissionDenied,
|
||||
ConnectionRefused,
|
||||
ConnectionReset,
|
||||
ConnectionAborted,
|
||||
NotConnected,
|
||||
AddrInUse,
|
||||
AddrNotAvailable,
|
||||
BrokenPipe,
|
||||
AlreadyExists,
|
||||
InvalidData,
|
||||
TimedOut,
|
||||
Interrupted,
|
||||
WriteZero,
|
||||
UnexpectedEof,
|
||||
BadResource,
|
||||
Http,
|
||||
Busy,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue