mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Improve std Error compatibility
This commit is contained in:
parent
84ffa91db9
commit
5fccd080c7
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user