JavaScript FatalError
just in case at some point you decide to break everything, regardless possible try catches around ...
how to use it?
P.S. it won't work if Errors are not logged ( silent failures, definitively a problem for certain applications ;) )
function FatalError(message, file, line){
function toString() {
throw e;
}
var e = this;
e["@message"] = message;
e["@file"] = file || e.file || e.fileName;
e["@line"] = line || e.line || e.lineNumber;
if ("__defineGetter__" in e) {
e.__defineGetter__("message", toString);
e.__defineGetter__("description", toString);
} else {
e.message = e.description = {toString: toString};
}
// just in case, but not necessary
e.toString = e.valueOf = toString;
};
(FatalError.prototype = new Error).name = "FatalError";
how to use it?
throw new FatalError("this must be a joke!");
P.S. it won't work if Errors are not logged ( silent failures, definitively a problem for certain applications ;) )
Comments
Post a Comment