32 lines
578 B
TypeScript
Raw Normal View History

2017-12-16 17:54:53 +01:00
export class Error {
2018-11-12 09:11:45 +01:00
name: string = "Error";
2017-12-16 17:54:53 +01:00
message: string;
stack: string = ""; // TODO
constructor(message: string = "") {
this.message = message;
}
2018-11-12 09:11:45 +01:00
toString(): string {
var message = this.message;
return message.length
? this.name + ": " + message
: this.name;
}
2017-12-16 17:54:53 +01:00
}
2018-11-12 09:11:45 +01:00
export class RangeError extends Error {
constructor(message: string = "") {
super(message);
this.name = "RangeError";
}
}
export class TypeError extends Error {
constructor(message: string = "") {
super(message);
this.name = "TypeError";
}
}