Error Handling Standards

The API follows the RFC 9457 (Problem Details for HTTP APIs) standard to ensure consistent and machine-readable error responses.

Standard Error Response

All error responses (4xx and 5xx) return a JSON body with the following structure:

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15",
  "title": "Bad Request",
  "status": 400,
  "detail": "The provided catalog name is already in use.",
  "instance": "/api/v1/catalogs",
  "errors": {
    "Name": ["Name must be unique within the company"]
  }
}

HTTP Status Codes

The system uses standard HTTP status codes to communicate the outcome of a request:

CodeMeaningUsage
200OKResource retrieved or updated successfully.
201CreatedResource created successfully.
400Bad RequestValidation errors or invalid business logic.
401UnauthorizedMissing or invalid JWT token.
403ForbiddenUser lacks permission for the specific resource.
404Not FoundThe requested resource does not exist.
500Internal ErrorUnexpected server-side exception.

Global Middleware

In the .NET Backend, the ExceptionMiddleware catches all unhandled exceptions and converts them into the standard Problem Details format. This ensures that even unexpected crashes do not leak internal stack traces to the client in production.