errors

Define domain-specific exception classes and map them to HTTP status codes.

Updated Apr 9, 2026
One-click install
npx skills add https://github.com/SergeuMatyasov/dotnet-shared-skills --skill errors-sergeumatyasov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: errors
Source: https://github.com/SergeuMatyasov/dotnet-shared-skills/tree/main/errors
Command: npx skills add https://github.com/SergeuMatyasov/dotnet-shared-skills --skill errors-sergeumatyasov

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill defines a standardized approach to error handling across .NET applications, ensuring predictable client-facing messages, safer logs, and easier maintenance.

Core Features & Use Cases

  • Dedicated exception classes for each business scenario.
  • Centralized mapping of domain errors to HTTP status codes and consistent error formats.
  • Clear separation between technical details for logs and user-facing messages in API responses.
  • Guidance for API contracts, validation schemas, and centralized exception handling.

Quick Start

Define a dedicated exception class for the new business condition and route it through the centralized error handler.

Frequently Asked Questions about errors

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

FAQPage Schema
How do I standardize .NET API error handling across different application layers?

To standardize .NET API error handling, define dedicated exception classes for business scenarios and route them through a centralized error handler. This enforces consistent API error formats, reliable HTTP status code mapping, and clear separation of user-facing messages from technical logs.

What is the best way to map domain exceptions to HTTP status codes in .NET?

The best way to map domain exceptions to HTTP status codes is using a centralized error handler. This framework maps your custom exception classes to appropriate HTTP responses and consistent error formats, ensuring predictable client-facing messages while keeping detailed stack traces safely in your logs.

How do I separate technical error details for logs from safe user-facing API responses?

You separate technical error details from safe user-facing API responses by implementing a centralized exception handler. It catches domain-specific exceptions, logs the full technical stack trace internally, and returns only standardized, safe error messages to the API client.

Does this error handling framework work for refactoring existing API error flows?

Yes, this framework works for refactoring existing API error flows. It provides a standardized approach to introduce new exception types, route them through centralized HTTP mappings, and enforce consistent API error formats across all application layers.

How do I implement centralized logging for custom exceptions in a .NET API?

You implement centralized logging for custom exceptions by routing all dedicated exception classes through a centralized error handler. This ensures robust diagnostic logging of technical details while simultaneously generating standardized, user-facing API error messages for the client.

When do I need to create domain-specific exception classes for my .NET API?

You need to create domain-specific exception classes when introducing new business conditions or enforcing coding standards. Defining a dedicated exception class for each business scenario allows the centralized handler to map it to the correct HTTP status code and consistent error format.