@visulima/error
Version:
Error with more than just a message, stacktrace parsing.
35 lines (33 loc) • 753 B
JavaScript
const isVisulimaError = (error) => error instanceof Error && error.type === "VisulimaError";
class VisulimaError extends Error {
loc;
title;
/**
* A message that explains to the user how they can fix the error.
*/
hint;
type = "VisulimaError";
constructor({ cause, hint, location, message, name, stack, title }) {
super(message, {
cause
});
this.title = title;
this.name = name;
this.stack = stack ?? this.stack;
this.loc = location;
this.hint = hint;
}
setLocation(location) {
this.loc = location;
}
setName(name) {
this.name = name;
}
setMessage(message) {
this.message = message;
}
setHint(hint) {
this.hint = hint;
}
}
export { VisulimaError, isVisulimaError };