UNPKG

@thisisagile/easy

Version:

Straightforward library for building domain-driven microservice architectures

40 lines (38 loc) 1.54 kB
import { Enum } from "./chunk-JVDKV5HE.mjs"; import { text } from "./chunk-MCCIBDEH.mjs"; import { asString } from "./chunk-BDA5LB4S.mjs"; import { isDefined } from "./chunk-DEJ7A5PY.mjs"; // src/types/Exception.ts var Exception = class _Exception extends Enum { constructor(message, id, reason) { super(message, id ?? text(message).pascal.toString()); this.message = message; this.reason = reason; } static AlreadyExists = new _Exception("Subject already exists"); static DoesNotExist = new _Exception("Does not exist"); static IsMissingId = new _Exception("Subject is missing an id"); static IsNotImplemented = new _Exception("Is not implemented"); static IsNotValid = new _Exception("Is not valid"); static Unknown = new _Exception("Unknown error"); static CouldNotExecute = (target) => new _Exception(`Could not execute ${target}.`, "CouldNotExecute"); static CouldNotValidate = (target) => new _Exception(`Could not validate ${target}.`, "CouldNotValidate"); static EnvironmentVariableNotFound = (variable) => new _Exception(`Environment variable ${text(variable).upper} could not be found.`, "EnvironmentVariableNotFound"); because = (reason) => new _Exception(this.message, this.id, reason); }; var isException = (e, t) => e instanceof Exception && (isDefined(t) ? e.equals(asString(t)) : true); var isDoesNotExist = (e) => e instanceof Exception && Exception.DoesNotExist.equals(e); export { Exception, isException, isDoesNotExist }; //# sourceMappingURL=chunk-FKZ4MOTX.mjs.map