envase
Version:
Type-safe environment variable validation with Standard Schema compliance
22 lines • 823 B
JavaScript
const symbol = Symbol.for('ENVASE_ERROR');
export class EnvaseError extends Error {
issues;
constructor(envvarValidationIssues) {
const parsedIssues = envvarValidationIssues
.map(({ name, value, messages }) => ` [${name}]:\n ${messages.join('\n ')}\n (received: "${value}")`)
.join('\n\n');
super(`Environment variables validation has failed:\n${parsedIssues}\n`);
Object.defineProperty(this, symbol, {
value: true,
});
this.name = this.constructor.name;
this.issues = envvarValidationIssues;
}
static isInstance(error) {
return (error !== null &&
typeof error === 'object' &&
symbol in error &&
error[symbol] === true);
}
}
//# sourceMappingURL=envase-error.js.map