summaryrefslogtreecommitdiff
path: root/cli/js/errors.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/errors.ts')
-rw-r--r--cli/js/errors.ts59
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,
};