You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.2 KiB
72 lines
2.2 KiB
|
5 months ago
|
import { CodeError, errCode, moduleSeed, type ErrCode, type ModuleSeed } from '$libs/errs';
|
||
|
|
import type { EidosValidationIssue } from './lib/config-types';
|
||
|
|
|
||
|
|
export const EIDOS_ERR: ModuleSeed = moduleSeed('eidos');
|
||
|
|
export const EIDOS_ERR_CONFIG: ErrCode = errCode(EIDOS_ERR, 'config');
|
||
|
|
export const EIDOS_ERR_CONTEXT: ErrCode = errCode(EIDOS_ERR, 'context');
|
||
|
|
export const EIDOS_ERR_NO_CONTEXT: ErrCode = errCode(EIDOS_ERR_CONTEXT, 'no_context');
|
||
|
|
export const EIDOS_ERR_CONFIG_VALIDATION: ErrCode = errCode(EIDOS_ERR_CONFIG, 'validation');
|
||
|
|
export const EIDOS_ERR_THEME_NOT_FOUND: ErrCode = errCode(EIDOS_ERR, 'theme_not_found');
|
||
|
|
export const EIDOS_ERR_CSS_VARIABLE: ErrCode = errCode(EIDOS_ERR, 'css_variable');
|
||
|
|
export const EIDOS_ERR_DOCUMENT: ErrCode = errCode(EIDOS_ERR, 'document');
|
||
|
|
|
||
|
|
export class ActiveEidosConfigError extends CodeError {
|
||
|
|
constructor(message: string, cause?: unknown) {
|
||
|
|
super(EIDOS_ERR_CONFIG, {
|
||
|
|
message: `[eidos] ${message}`,
|
||
|
|
cause
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export class ActiveEidosNoContextError extends CodeError {
|
||
|
|
constructor() {
|
||
|
|
super(EIDOS_ERR_NO_CONTEXT, {
|
||
|
|
message:
|
||
|
|
'[eidos] No ActiveEidos context found. Call ActiveEidos.create() in the consumer tree that needs visual components.'
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export class EidosConfigValidationError extends CodeError {
|
||
|
|
readonly issues: readonly EidosValidationIssue[];
|
||
|
|
|
||
|
|
constructor(issues: readonly EidosValidationIssue[]) {
|
||
|
|
super(EIDOS_ERR_CONFIG_VALIDATION, {
|
||
|
|
message: `[eidos] invalid config: ${issues.map((issue) => issue.path).join(', ')}`
|
||
|
|
});
|
||
|
|
this.issues = issues;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export class EidosThemeNotFoundError extends CodeError {
|
||
|
|
readonly themeId: string;
|
||
|
|
|
||
|
|
constructor(themeId: string) {
|
||
|
|
super(EIDOS_ERR_THEME_NOT_FOUND, {
|
||
|
|
message: `[eidos] theme "${themeId}" is not configured`
|
||
|
|
});
|
||
|
|
this.themeId = themeId;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export class EidosCssVariableError extends CodeError {
|
||
|
|
readonly variables: readonly string[];
|
||
|
|
|
||
|
|
constructor(variables: readonly string[]) {
|
||
|
|
super(EIDOS_ERR_CSS_VARIABLE, {
|
||
|
|
message: `[eidos] unknown or invalid CSS variables: ${variables.join(', ')}`
|
||
|
|
});
|
||
|
|
this.variables = variables;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export class EidosConfigDocumentError extends CodeError {
|
||
|
|
constructor(message: string, cause?: unknown) {
|
||
|
|
super(EIDOS_ERR_DOCUMENT, {
|
||
|
|
message: `[eidos] ${message}`,
|
||
|
|
cause
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|