error-handling

Define Result-based error handling with RFC 9457 ProblemDetails for .NET 10 APIs.

224|87|Updated Dec 15, 2018
One-click install
npx skills add https://github.com/Resgrid/Core --skill error-handling-resgrid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/Resgrid/Core/tree/main/.opencode/skills/error-handling
Command: npx skills add https://github.com/Resgrid/Core --skill error-handling-resgrid

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents inconsistent and ad-hoc error responses by providing a clear strategy for handling validation failures, expected business outcomes, and unexpected exceptions in .NET 10 APIs.

Core Features & Use Cases

  • Use the Result pattern for expected failures to represent business-rule outcomes like “order not found” or “validation failed” without throwing exceptions.
  • Return RFC 9457 ProblemDetails for every API error so clients receive consistent type, title, status, detail, and optional errors.
  • Validate at the boundary using FluentValidation and endpoint filters to catch invalid requests early and map validation failures to standard error responses.
  • Centralize unexpected exceptions with a global exception handler that logs and converts crashes into safe ProblemDetails responses (including development-friendly detail).

Quick Start

Load the error-handling skill and implement your API endpoints so expected failures use Result-to-ProblemDetails mappings while unexpected exceptions are caught globally and returned as ProblemDetails.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I standardize API error responses in .NET using ProblemDetails?

Standardize API error responses in .NET by mapping validation failures and exceptions to RFC 9457 ProblemDetails. This provides a consistent shape with type, title, status, and detail fields across both controller and minimal API routes.

What's the best way to handle expected business failures without throwing exceptions in .NET 10?

Handle expected business failures in .NET 10 using the Result pattern to model outcomes like validation errors or missing records. Map these Result objects directly to standard ProblemDetails responses without relying on exception throwing.

How do I validate API requests at the boundary using FluentValidation?

Validate API requests at the boundary using FluentValidation combined with endpoint filters. This catches invalid requests early and automatically maps validation failures into standard ProblemDetails error responses.

How do I prevent leaking sensitive details during global exception handling in production?

Prevent leaking sensitive details by implementing a global exception handler that catches unexpected crashes and logs them securely. It converts crashes into safe ProblemDetails responses, providing development-friendly details only outside production.

Does the Result pattern work with both minimal APIs and controllers in .NET?

Yes, the Result pattern works with both minimal APIs and controllers in .NET. It consistently maps expected failure outcomes and boundary validation errors to uniform HTTP status codes and ProblemDetails contracts.