Skip to content
rw3iss Auth

ErrorMapper

class rw3iss\AuthServer\Http\ErrorMapper src/Http/ErrorMapper.php ↗

Map (HTTP status, error envelope) → typed exception subclass.

The auth-server envelope (pkg/shared/errors.WriteAPIError): { “code”: “TOKEN_EXPIRED”, “message”: ”…”, “details”: {…}, “request_id”: ”…” }

Some endpoints (legacy) use { “error”: { “code”, “message” } } — we defensively parse both shapes.

Methods

fromResponse()

function fromResponse(int $status, ?array $body, array $headers = []): VenAuthException

Build the appropriate exception. Caller is responsible for throwing.

Parameters

  • $bodyarray<string,mixed>|null · decoded JSON body (or null on parse failure)
  • $headersarray<string,list<string>> · HTTP response headers

map429()

function map429(string $message, array $headers, array $details): RateLimitedException

Parameters

  • $headersarray<string,list<string>>
  • $detailsarray<string,mixed>

parseEnvelope()

function parseEnvelope(?array $body): array

Parameters

  • $bodyarray<string,mixed>|null

Returns

  • array{code:?string,message:?string,details:array<string,mixed>}