ErrorMapper
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 = []): VenAuthExceptionBuild the appropriate exception. Caller is responsible for throwing.
Parameters
$body—array<string,mixed>|null· decoded JSON body (or null on parse failure)$headers—array<string,list<string>>· HTTP response headers
map429()
function map429(string $message, array $headers, array $details): RateLimitedExceptionParameters
$headers—array<string,list<string>>$details—array<string,mixed>
parseEnvelope()
function parseEnvelope(?array $body): arrayParameters
$body—array<string,mixed>|null
Returns
array{code:?string,message:?string,details:array<string,mixed>}