diff options
author | Stanislav <62983943+stanislavstrelnikov@users.noreply.github.com> | 2020-07-07 04:45:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 21:45:39 -0400 |
commit | 158ae0bfe900d2bac3076390c4fe3d2b54d94fe5 (patch) | |
tree | 209e4b5682e2a899041767c49428e34329e48084 /cli/js/errors.ts | |
parent | ab4c574f5202f607ceb6068f56b3cc8aed1bbbaf (diff) |
clean up code in cli/js (#6611)
Diffstat (limited to 'cli/js/errors.ts')
-rw-r--r-- | cli/js/errors.ts | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/cli/js/errors.ts b/cli/js/errors.ts index 69afcf148..52c5e50ad 100644 --- a/cli/js/errors.ts +++ b/cli/js/errors.ts @@ -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, }; |