# Class ErrorHandlerMiddleware

Namespace
  adas_core.ErrorMiddleware

Assembly
  adas-core.dll

Represents an ASP.NET Core middleware that handles errors occurring during the request processing pipeline.

    public class ErrorHandlerMiddleware

Inheritance
  object
  ErrorHandlerMiddleware

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Remarks

This middleware is typically registered in the application's request pipeline to intercept and handle exceptions thrown by subsequent middleware components, while leveraging the injected logger to record error information.

## Constructors

### ErrorHandlerMiddleware(RequestDelegate, ILogger<ErrorHandlerMiddleware>)

Represents an ASP.NET Core middleware that handles errors occurring during the request processing pipeline.

    public ErrorHandlerMiddleware(RequestDelegate next, ILogger<ErrorHandlerMiddleware> logger)

#### Parameters

`next` RequestDelegate
`logger` ILogger<ErrorHandlerMiddleware>

#### Remarks

This middleware is typically registered in the application's request pipeline to intercept and handle exceptions thrown by subsequent middleware components, while leveraging the injected logger to record error information.

## Methods

### InvokeAsync(HttpContext)

Middleware that catches unhandled exceptions, maps known domain exceptions to appropriate HTTP status codes, and writes a standardized ProblemDetails response with a correlation `traceId`. For unrecognized exceptions, it falls back to a 500 Internal Server Error response without exposing internal details.

    public Task InvokeAsync(HttpContext context)

#### Parameters

`context` HttpContext

  The current HTTP request context used to invoke the next middleware, read the trace identifier, and write the error response.

#### Returns

Task