44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* Error types raised by the config and env loaders.
|
|
*
|
|
* These are deliberately distinct from `Error` subclasses inside `@elly/core`
|
|
* or `@elly/bot` — they cross the workspace boundary and must be importable
|
|
* by both runtimes without dragging unrelated dependencies along.
|
|
*/
|
|
|
|
export class ConfigError extends Error {
|
|
readonly path: string;
|
|
|
|
constructor(message: string, path: string) {
|
|
super(message);
|
|
this.name = "ConfigError";
|
|
this.path = path;
|
|
}
|
|
}
|
|
|
|
export class ConfigValidationError extends ConfigError {
|
|
readonly issues: readonly ConfigValidationIssue[];
|
|
|
|
constructor(message: string, path: string, issues: readonly ConfigValidationIssue[]) {
|
|
super(message, path);
|
|
this.name = "ConfigValidationError";
|
|
this.issues = issues;
|
|
}
|
|
}
|
|
|
|
export interface ConfigValidationIssue {
|
|
readonly path: string;
|
|
readonly message: string;
|
|
readonly code: string;
|
|
}
|
|
|
|
export class EnvValidationError extends Error {
|
|
readonly issues: readonly ConfigValidationIssue[];
|
|
|
|
constructor(message: string, issues: readonly ConfigValidationIssue[]) {
|
|
super(message);
|
|
this.name = "EnvValidationError";
|
|
this.issues = issues;
|
|
}
|
|
}
|