(Init): Added shit
This commit is contained in:
43
crates/shared/src/config/errors.ts
Normal file
43
crates/shared/src/config/errors.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user