// https://www.w3schools.com/js/js_errors.asp
try {
// Fehler
oops();
}
catch(e) {
// komplette Message
console.log(e);
// Fehlername
console.log(e.name);
// Message
console.log(e.message);
// Aufrufstack
console.log(e.stack);
}
finally {
console.log("Finally.");
}
Kategorie: Exceptions
[JavaScript] Eigene Exceptions werfen
// https://www.w3schools.com/js/js_errors.asp
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
try {
throw new Error("Ein Error.");
// throw new EvalError("Ein EvalError.");
// throw new RangeError("Ein RangeError.");
// throw new ReferenceError("Ein ReferenceError.");
// throw new SyntaxError("Ein SytaxError.");
// throw new TypeError("Ein TypeError.");
// throw new URIError("Ein URIError.");
}
catch(e) {
console.log(e);
}