/** * Errors thrown by the auth bridge. * * Each implements `KernelErrorClassifiable` so `kernel-api/dispatch` can * convert them into typed `KernelErrorPayload` values automatically. */ import type { KernelErrorPayload, KernelErrorClassifiable } from '@astrale-os/kernel-api' import { KERNEL_ERROR_CODES } from '@astrale-os/kernel-api' export class AuthMissingError extends Error implements KernelErrorClassifiable { constructor() { super('Missing credentials') this.name = 'AuthMissingError' } toKernelErrorPayload(): KernelErrorPayload { return { code: KERNEL_ERROR_CODES.AUTH_MISSING, message: this.message } } } export class AuthInvalidError extends Error implements KernelErrorClassifiable { constructor(message: string, cause?: unknown) { super(message, { cause }) this.name = 'AuthInvalidError' } toKernelErrorPayload(): KernelErrorPayload { return { code: KERNEL_ERROR_CODES.AUTH_INVALID, message: this.message } } }