Apply the canonical error pattern (docs/conventions.md rule 6) to the remaining 16 modules: every module's <MOD>_ERR seed, <MOD>_ERR_* codes, <MOD>_ERROR_MESSAGES catalogue, error classes and is*Error guards now live in a single errors.ts file. consts.ts retains only configuration unrelated to errors (event names, default values, op identifiers). Modules consolidated: - libs/active-app, libs/auth, libs/bus, libs/cache, libs/dom, libs/lang, libs/perm, libs/timer (new errors.ts) - arts/active-app, arts/auth, arts/connection, arts/http, arts/logger, arts/perm, arts/session, arts/sium - svrs/perm `<MOD>_ERROR_MESSAGES: ErrorMessages` declared in every module, indexed by ErrCode. The ErrorMessages type was added to libs/errs/code in the previous pass; this commit propagates its use everywhere. `libs/errs/consts.ts` is the documented exception: its codes (`errs::format_invalid`, `errs::unknown`) live as string literals in consts.ts because errors.ts imports them and code.ts imports CodeFormatError from errors.ts — the import graph forbids using errCode() at that position. Side cleanups: - libs/cache: legacy CACHE_ERROR_MESSAGES dict (validation strings) renamed to CACHE_VALIDATION_MESSAGES so the canonical CACHE_ERROR_MESSAGES (ErrorMessages indexed by ErrCode) is the only symbol with that name. - libs/perm: PERM_MODULE = 'perm' added (it was implicit before). - arts/auth, arts/perm, arts/active-app: client-only error codes (request_failed, disposed, invalid_response, no_context, etc.) live in the artifact's errors.ts but reuse the libs <MOD>_ERR seed so every code in the family shares the same module prefix. - libs/timer: errors.ts created (didn't exist) housing the codes that were previously in consts.ts; library has no classes (timer error classes live in arts/timer/errors.ts and import the codes from libs/timer). - arts/sium: SIUM_ERR seed, codes and three error classes (SiumValidationError, SiumAsyncSchemaError, SiumDiscriminatedUnionError) consolidated. Classes were previously in core/types.ts; that file no longer carries error infrastructure. All call sites in arts/sium/core/* and arts/sium/types/* updated their imports from `./types`/`../core/types` to the module's `errors.ts`. All 1334 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>master
parent
7f2577c8da
commit
0b2c4eb30b
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,27 @@
|
||||
import {
|
||||
errCode,
|
||||
moduleSeed,
|
||||
type ErrCode,
|
||||
type ErrorMessages,
|
||||
type ModuleSeed
|
||||
} from '$libs/errs';
|
||||
import { TIMER_MODULE } from './consts.ts';
|
||||
|
||||
// ── Error codes ────────────────────────────────────────────────────────
|
||||
|
||||
export const TIMER_ERR: ModuleSeed = moduleSeed(TIMER_MODULE);
|
||||
export const TIMER_ERR_DISPOSED: ErrCode = errCode(TIMER_ERR, 'disposed');
|
||||
export const TIMER_ERR_INVALID_KEY: ErrCode = errCode(TIMER_ERR, 'invalid_key');
|
||||
export const TIMER_ERR_DUPLICATE_KEY: ErrCode = errCode(TIMER_ERR, 'duplicate_key');
|
||||
export const TIMER_ERR_INVALID_DELAY: ErrCode = errCode(TIMER_ERR, 'invalid_delay');
|
||||
export const TIMER_ERR_INACTIVE_TIMER: ErrCode = errCode(TIMER_ERR, 'inactive_timer');
|
||||
|
||||
// ── Error messages ─────────────────────────────────────────────────────
|
||||
|
||||
export const TIMER_ERROR_MESSAGES: ErrorMessages = {
|
||||
[TIMER_ERR_DISPOSED]: `[${TIMER_MODULE}] operation called on a disposed timer scheduler`,
|
||||
[TIMER_ERR_INVALID_KEY]: `[${TIMER_MODULE}] invalid timer key`,
|
||||
[TIMER_ERR_DUPLICATE_KEY]: `[${TIMER_MODULE}] timer key already scheduled`,
|
||||
[TIMER_ERR_INVALID_DELAY]: `[${TIMER_MODULE}] invalid timer delay`,
|
||||
[TIMER_ERR_INACTIVE_TIMER]: `[${TIMER_MODULE}] timer key is not active`
|
||||
};
|
||||
@ -1,4 +1,5 @@
|
||||
export * from './backoff.ts';
|
||||
export * from './consts.ts';
|
||||
export * from './debounce.ts';
|
||||
export * from './errors.ts';
|
||||
export * from './types.ts';
|
||||
|
||||
Loading…
Reference in new issue