Improve std Error compatibility

This commit is contained in:
dcodeIO 2018-11-12 09:11:45 +01:00
parent 84ffa91db9
commit 5fccd080c7

View File

@ -1,12 +1,31 @@
export class Error { export class Error {
name: string = "Error";
message: string; message: string;
stack: string = ""; // TODO stack: string = ""; // TODO
constructor(message: string = "") { constructor(message: string = "") {
this.message = message; this.message = message;
} }
toString(): string {
var message = this.message;
return message.length
? this.name + ": " + message
: this.name;
}
} }
export class RangeError extends Error {} export class RangeError extends Error {
export class TypeError extends Error {} constructor(message: string = "") {
super(message);
this.name = "RangeError";
}
}
export class TypeError extends Error {
constructor(message: string = "") {
super(message);
this.name = "TypeError";
}
}