@hazae41/result
Version:
Rust-like Result for TypeScript
23 lines (21 loc) • 498 B
JavaScript
/**
* An error that should have been prevented by the type system
*/
class Panic extends Error {
#class = Panic;
name = this.#class.name;
}
/**
* An non-error that was caught by a catch clause
*/
class Catched extends Error {
#class = Catched;
name = this.#class.name;
static wrap(cause) {
if (cause instanceof Error)
return cause;
return new Catched(undefined, { cause });
}
}
export { Catched, Panic };
//# sourceMappingURL=errors.mjs.map