ExAzureCore.Http.Plugins.ErrorHandler (ex_azure_core v0.2.0)

Copy Markdown

Req plugin that transforms HTTP error responses to Splode errors.

Parses Azure error response format and maps to appropriate error types:

  • 401/403 - Returns the response for auth-specific handling
  • 400 - Maps to HttpError with parsed error details
  • 4xx - Maps to HttpError
  • 5xx - Maps to HttpError

Azure Error Format

Azure services return errors in the format:

{
  "error": {
    "code": "ErrorCode",
    "message": "Error message",
    "details": [...]
  }
}

Options

  • :raise_on_error - Raise exception instead of returning {:error, _} (default: false)

Example

req = Req.new()
|> ExAzureCore.Http.Plugins.ErrorHandler.attach()

Summary

Functions

Attaches the error handler plugin to a Req request.

Functions

attach(request, opts \\ [])

@spec attach(
  Req.Request.t(),
  keyword()
) :: Req.Request.t()

Attaches the error handler plugin to a Req request.