UNPKG

@hazae41/result

Version:

Rust-like Result for TypeScript

26 lines (23 loc) 536 B
'use strict'; /** * 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 }); } } exports.Catched = Catched; exports.Panic = Panic; //# sourceMappingURL=errors.cjs.map