stacks-error-handling

Handle Stacks runtime errors with Result types, error pages, and logging.

622|17|Updated Apr 26, 2022
One-click install
npx skills add https://github.com/stacksjs/stacks --skill stacks-error-handling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stacks-error-handling
Source: https://github.com/stacksjs/stacks/tree/main/.claude/skills/stacks-error-handling
Command: npx skills add https://github.com/stacksjs/stacks --skill stacks-error-handling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Type-safe error handling for Stacks projects, enabling reliable error capture, standardized responses, and structured logging across the stack.

Core Features & Use Cases

  • Result types with Ok/Err and fromPromise for predictable error flows.
  • Error page rendering and mapping for dev vs prod environments.
  • Centralized error logging and exceptions like ModelNotFoundException for robust data access layers.

Quick Start

Install stacks-error-handling in your project and start using the provided APIs to unify error handling across your codebase.

Frequently Asked Questions about stacks-error-handling

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle runtime errors type-safely in TypeScript applications?

Type-safe error handling in TypeScript uses Result types with Ok and Err variants to capture predictable error flows. This approach standardizes error responses and structures logging across your application environments.

What is the best way to standardize error pages and logging across different environments?

Standardizing error pages and logging is achieved through a configurable log system that maps HTTP errors and renders environment-specific pages. This framework separates development page rendering from production responses for consistent exception handling.

How do I convert JavaScript Promises into Result types for predictable error flows?

You convert Promises into Result types using the fromPromise utility, wrapping asynchronous operations in a type-safe Ok or Err object. This mechanism ensures predictable error flows without relying on try-catch blocks.

Does this error-handling approach work for APIs and core framework services?

Yes, this error-handling framework applies to core framework development, APIs, and services. It provides centralized error logging and standardized exceptions like ModelNotFoundException for robust data access layers.

When should I use Result types instead of throwing exceptions in a Stacks app?

Use Result types when you need type-safe, predictable error flows across your stack instead of unpredictable thrown exceptions. This approach enables reliable error capture and structured logging for consistent application responses.

How do I map HTTP errors and render appropriate error pages in a Stacks project?

Mapping HTTP errors involves using the framework's error-page rendering and HTTP error mapping features to generate environment-specific responses. This standardizes how exceptions display during development versus production.