import { CodeError, errCode, moduleSeed, type ErrCode, type ModuleSeed } from '$libs/errs'; export const SEMA_ERR: ModuleSeed = moduleSeed('sema'); export const SEMA_ERR_CONFIG: ErrCode = errCode(SEMA_ERR, 'config'); export const SEMA_ERR_INVARIANT: ErrCode = errCode(SEMA_ERR, 'invariant'); export const SEMA_ERR_DUPLICATE_CHANNEL: ErrCode = errCode(SEMA_ERR, 'duplicate_channel'); export class SemaConfigError extends CodeError { constructor(message: string) { super(SEMA_ERR_CONFIG, { message: `[sema] ${message}` }); } } export class SemaInvariantError extends CodeError { constructor(message: string) { super(SEMA_ERR_INVARIANT, { message: `[sema] ${message}` }); } } export class SemaDuplicateChannelError extends CodeError { readonly channelId: string; constructor(channelId: string) { super(SEMA_ERR_DUPLICATE_CHANNEL, { message: `[sema] channel with id "${channelId}" already registered` }); this.channelId = channelId; } }