error-handling

Handle typed TRPC errors with formatting and global logging.

Updated Jun 26, 2025
One-click install
npx skills add https://github.com/flaviogragnolati/coco --skill error-handling-flaviogragnolati
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/flaviogragnolati/coco/tree/main/.agents/skills/error-handling
Command: npx skills add https://github.com/flaviogragnolati/coco --skill error-handling-flaviogragnolati

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @trpc/server, and includes scripts (resource) components.

What problem does it solve?

This Skill addresses the challenges of error management in TRPC applications, providing structured error handling, clear client-side error display, and global error logging.

Core Features & Use Cases

  • Typed Errors: Utilizes TRPCError for precise error signaling.
  • Error Formatting: Customizes error display for a better user experience.
  • Global Error Handling: Offers a robust way to manage errors globally.
  • HTTP Status Mapping: Maps TRPC errors to appropriate HTTP status codes.
  • Use Case: For a server that relies on TRPC for API communication, this Skill ensures that errors are handled cleanly and effectively, improving both user experience and server stability.

Quick Start

Initialize the error handling mechanism by setting up errorFormatter in your server configuration.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I handle typed errors in tRPC server applications?

Typed errors in tRPC server applications are handled using the TRPCError object to signal precise errors, format client-side displays, and manage global error logging. This ensures robust error management and clear client communication.

How do I map tRPC errors to appropriate HTTP status codes?

Mapping tRPC errors to HTTP status codes is achieved through the Skill's error handling mechanism. It automatically translates TRPCError types into appropriate HTTP status codes to ensure clients receive accurate HTTP responses.

How do I set up global error logging for a tRPC API?

Global error logging for a tRPC API is configured by initializing the errorFormatter in your server configuration. This setup provides a robust way to globally manage and log application errors across your server.

Can I customize error formatting for tRPC client responses?

Yes, customizing error formatting for tRPC client responses is a core feature. By configuring the errorFormatter, you can customize the error display structure to improve the user experience and ensure clear client-side error communication.

Does this tRPC error handling approach require specific dependencies?

Yes, implementing this tRPC error handling approach requires the @trpc/server dependency. It is designed exclusively for applications using tRPC for API communication to structure error handling and signaling effectively.