cck-error-handling

Return typed Result objects from handlers and map them to ProblemDetails responses.

2|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/s205109/AHKFlowApp --skill cck-error-handling
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cck-error-handling
Source: https://github.com/s205109/AHKFlowApp/tree/main/.claude/skills/cck-error-handling
Command: npx skills add https://github.com/s205109/AHKFlowApp --skill cck-error-handling

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a consistent, production-ready approach to representing expected failures and unexpected errors in ASP.NET APIs so controllers return uniform, machine-readable error responses instead of ad-hoc strings or thrown exceptions.

Core Features & Use Cases

  • Uses Ardalis.Result to model typed outcomes (Success, NotFound, Invalid, Conflict, Error) so handlers avoid throwing for expected flow control.
  • Enforces request validation via a MediatR ValidationBehavior with FluentValidation to ensure handlers only receive valid requests.
  • Maps domain results to HTTP automatically using result.ToActionResult in controllers and returns ProblemDetails (RFC 9457) for API errors.
  • Provides a GlobalExceptionMiddleware to log unhandled exceptions and return RFC-compliant ProblemDetails 500 responses.
  • Use case: build CRUD endpoints that return consistent status codes for not-found, validation errors, conflicts, and unexpected server faults.

Quick Start

Return typed Ardalis.Result from handlers, register ValidationBehavior and FluentValidation in DI, and map responses in controllers using result.ToActionResult(this).

Frequently Asked Questions about cck-error-handling

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

FAQPage Schema
How do I return RFC 9457 ProblemDetails for ASP.NET Core API errors?

To return RFC 9457 ProblemDetails for ASP.NET Core API errors, map typed Result objects to HTTP using result.ToActionResult in controllers, and implement GlobalExceptionMiddleware to catch unhandled exceptions and return compliant 500 responses automatically.

What is the best way to handle expected validation failures without throwing exceptions in MediatR?

The best way to handle expected validation failures without throwing exceptions is using a MediatR ValidationBehavior pipeline with FluentValidation to intercept invalid requests, returning typed Ardalis.Result objects like Invalid or Conflict instead of relying on exceptions for flow control.

Can I use FluentValidation with MediatR pipelines to enforce request validation in ASP.NET Core?

Yes, you can use FluentValidation with MediatR pipelines by registering a custom ValidationBehavior in dependency injection to validate requests before they reach handlers, ensuring handlers only process valid inputs and return typed Ardalis.Result outcomes.

Why should I use Ardalis.Result instead of throwing exceptions for expected API failures?

You should use Ardalis.Result instead of throwing exceptions for expected API failures because it models typed outcomes like Success, NotFound, and Conflict explicitly, reserving exceptions for unpredictable infrastructure errors and producing uniform machine-readable HTTP responses.

When should I use GlobalExceptionMiddleware versus typed Result objects in ASP.NET Core?

Use GlobalExceptionMiddleware for unpredictable infrastructure errors that require logging and a 500 ProblemDetails response, and use typed Ardalis.Result objects for expected flow control failures like validation errors, not-found resources, or conflicts to avoid throwing exceptions.