@deftomat/opinionated
Version:
Opinionated tooling for JavaScript & TypeScript projects.
31 lines (30 loc) • 794 B
JavaScript
/**
* Represents an fatal error raised by tool.
*
* `ToolError` should be handled and app should fail immediately.
*/
export class ToolError extends Error {
constructor(...messages) {
super(messages.join('\n'));
Error.captureStackTrace(this, ToolError);
this.messages = messages;
}
static is(error) {
return error instanceof ToolError;
}
}
/**
* Represents an warning raised by tool.
*
* `ToolWarning` should be handled and app should continue with warnings.
*/
export class ToolWarning extends Error {
constructor(...messages) {
super(messages.join('\n'));
Error.captureStackTrace(this, ToolWarning);
this.messages = messages;
}
static is(error) {
return error instanceof ToolWarning;
}
}