I would like Chrome Dev Tools to log my custom Error objects (extending Error) in the same user-friendly format as a native browser Error.
Currently the following code:
console.log(new CustomError('boom'));
console.log(new Error('boom'));
Produces the following output:
Instead, I would like my custom error type to display with the ellipsised (...) stack trace, with it's convenient clickable file paths when expanded.
My current error implementation is the suggested method of extension from MDN Custom Error types document, although I have also tried this and this Stack Overflow answer.
The MDN implementation, with added captureStackTrace support, is:
function CustomError(message) {
this.message = message;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
} else {
this.stack = new Error().stack;
}
}
Object.setPrototypeOf(CustomError, Error);
CustomError.prototype = Object.create(Error.prototype);
CustomError.prototype.name = "CustomError";
CustomError.prototype.message = "";
CustomError.prototype.constructor = CustomError;
Is there are way to get Chrome Dev Tools to see my custom error as a standard Error?
