My custom Error class:
function MyError(message) {
this.message = message || "";
}
MyError.prototype = new Error();
MyError.prototype.name = "MyError";
MyError.prototype.toString = function() {
return "[" + this.name + "] " + this.message;
};
If I run throw new MyError("test")
then FF/IE console shows a default message instead of the expected [MyError] test
.
How do I get the JS engine to use my toString()
method?