plugins/smedjen/skills/error-handling-patterns/SKILL.md
Consistent error handling across codebases. Error boundaries, try-catch patterns, custom error types, logging strategies, and graceful degradation.
npx skillsauth add hjemmesidekongen/ai error-handling-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Base AppError with fields: message, code, statusCode, isOperational. All domain errors extend it. This lets catch blocks discriminate by type and middleware map errors to HTTP responses automatically.
Subclasses: ValidationError (400, fields map), AuthError (401/403), NotFoundError (404, resource + id), ConflictError (409), ExternalServiceError (502, service name + original error), RateLimitError (429, retryAfter).
Mark isOperational: true for expected errors (bad input, missing resource). Non-operational errors (null deref, OOM) should crash — they're bugs, not user problems.
Every logged error must include: error_code (machine-readable, e.g. AUTH_TOKEN_EXPIRED), message, stack (dev/staging only — strip in prod), context (request ID, user ID, route, input summary), severity (error/warn/info), timestamp (ISO 8601 UTC), service (originating module).
Never log raw error.message from external services — may contain PII or credentials. Sanitize first.
Place boundaries at feature boundaries, not per-component or root-only:
Configure Sentry (or equivalent) with: environment tags, release version, user context (anonymized), breadcrumbs for last 10 actions. Filter out: isOperational errors that are expected (4xx from valid user actions). Alert on: unhandled rejections, error rate spikes, new error types not seen before.
See references/process.md for custom error class templates and structured logging field definitions.
development
Creates a brand from scratch through market research and interactive sparring. Runs competitive research via Perplexity, then guides the user through positioning, audience, voice, values, and content pillars. Produces the full brand guideline set at .ai/brand/{name}/. Use when building a new brand, defining brand strategy for a product, or when /våbenskjold:create is invoked.
testing
Loads brand guidelines from .ai/brand/{name}/ and makes them available to the current context. Progressive disclosure: L1 confirms brand exists, L2 loads summary, L3 loads specific files on demand. Use when a downstream skill or user needs brand context, or when /våbenskjold:apply is invoked.
documentation
Guided reinvention of an existing brand guideline. Loads current brand from .ai/brand/{name}/, identifies what to keep vs change, and walks the user through targeted evolution. Preserves brand equity while updating positioning, voice, or values. Use when refreshing a brand or when /våbenskjold:evolve is invoked.
development
Codifies an existing brand from materials, samples, and references. Analyzes provided content to extract voice patterns, values, and positioning. Produces the same guideline format as brand-strategy. Use when a brand already exists but isn't documented, or when /våbenskjold:audit is invoked.