phycool-error-handling

Implements standardized error codes and RFC 7807 ProblemDetails handling for ASP.NET Core APIs.

10|3|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-error-handling-cynthia1070711
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: phycool-error-handling
Source: https://github.com/Cynthia1070711/PHYCOOL_Tools/tree/main/config-templates/claude/skills/phycool-error-handling
Command: npx skills add https://github.com/Cynthia1070711/PHYCOOL_Tools --skill phycool-error-handling-cynthia1070711

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? It standardizes how a full-stack ASP.NET Core and TypeScript application defines, returns, and displays errors, eliminating ad-hoc error strings, leaked stack traces, and inconsistent frontend error handling. ## Core Features & Use Cases - ErrorCode Enum + Registry: Define every error as an enum value with an [ErrorCodeInfo] attribute (HTTP status, user message, handling suggestion), cached in a singleton ErrorCodeRegistry for O(1) lookup. - RFC 7807 ProblemDetails Pipeline: ExceptionHandlerMiddleware and ControllerErrorExtensions.ProblemResult() return structured problem+json responses with traceId, never exposing SQL details or stack traces in production. - Frontend Integration: TypeScript isKnownErrorCode type guards, handleApiError with default strategies (login redirect, upgrade prompt, toast), plus preflight validator error code ranges for editor features. - Use Case: When adding a new API error, register it in ErrorCode.cs with its attribute, return it via ProblemResult in the controller, and the frontend automatically maps it to a localized user-facing toast. ## Quick Start Ask the AI to add a new error code for a failed operation and wire it through the backend ProblemResult response and frontend toast mapping following this skill's standards.

Frequently Asked Questions about phycool-error-handling

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

FAQPage Schema
How do I add a new error code in ASP.NET Core with RFC 7807 ProblemDetails?

Add an enum value to ErrorCode.cs with an [ErrorCodeInfo] attribute specifying HTTP status, internal ID, and user message. Return it from controllers via this.ProblemResult(_errorRegistry, ErrorCode.YOUR_CODE), which produces a standards-compliant problem+json response.

How to handle exceptions globally in ASP.NET Core middleware?

Place ExceptionHandlerMiddleware at the outermost pipeline position to catch all exceptions. It maps DbUpdateException FK violations (SqlException 547) to HTTP 409, generic exceptions to HTTP 500 ProblemDetails, and re-throws for MVC paths.

Should I use Promise.all or Promise.allSettled for batch operations?

Use Promise.allSettled when partial success is acceptable, since it lets each item settle independently and you can collect failures into warnings. Promise.all rejects entirely on the first failure, which breaks batch UX when only one item is bad.

Why does [FromBody] enum binding fail while [FromQuery] works in ASP.NET Core?

[FromBody] uses System.Text.Json, which throws on string enum names without a converter, while [FromQuery] uses TypeConverter which accepts strings. Register JsonStringEnumConverter in both ConfigureHttpJsonOptions and AddJsonOptions to fix body binding.

What error details are safe to expose in production API responses?

Production responses should contain only a generic detail message plus a traceId for log correlation. Never expose stack traces, exception messages, or SqlException details; development environments may include ex.Message for debugging.