@delightstack/utilities
v1.0.0
Published
Framework-agnostic TypeScript utilities for Delightstack — the DelightError error class, reactive Svelte 5 helpers, attachments, and DOM utilities.
Maintainers
Readme
@delightstack/utilities
Framework-agnostic TypeScript utilities shared across the Delightstack
packages — the DelightError error class, reactive helpers, attachments, and DOM utilities.
Install
pnpm add @delightstack/utilitiesThe reactive helpers and attachments use Svelte 5 runes, so svelte is an optional peer
dependency (only required if you import those entry points).
Error handling
DelightError is the single operational error class used by every Delightstack package.
import { DelightError } from '@delightstack/utilities';
throw DelightError.badRequest('Invalid input'); // 400
throw DelightError.unauthorized('Not authenticated'); // 401
throw DelightError.notFound('Resource not found'); // 404
// Full options
throw new DelightError({ message: 'Boom', status: 500, code: 'INTERNAL_ERROR' });
// Normalize unknowns + serialize
const err = DelightError.from(unknown);
return err.toResponse(); // → ResponseDocumentation
Full docs: https://docs.thedelight.co
License
MIT © Brian Schwabauer
