AXIAM PHP SDK

ErrorMapper
in package

FinalYes

Central status→error mapper (CONTRACT.md §2, D-10). {@see self::fromStatus()} is the single translation point from an HTTP status code to a typed {@see AxiamException} subtype — no other class in the SDK is permitted to hand-roll this branching: 401 → {@see AuthError}; 403/409 → {@see AuthzError}; everything else (400/408/429/5xx/transport) → {@see NetworkError}.

Table of Contents

Methods

fromOAuth2Response()  : AxiamException
The `/oauth2/*` translation point (CONTRACT.md §12.3 rule 3): a `400` from `POST /oauth2/token`, or a `401` from `POST /oauth2/introspect` / `POST /oauth2/revoke`, carrying an `OAuth2ErrorResponse` body (`{error, error_description}`) MUST surface as {@see OAuthProtocolError} rather than the generic {@see self::fromStatus()} mapping (which would otherwise collapse a `400` into a plain {@see NetworkError}, or a `401` into a plain {@see AuthError} that would wrongly enter the §9 single-flight refresh guard, §12.3 rule 3).
fromResponse()  : AxiamException
Convenience wrapper for callers that already hold a live PSR-7 response — delegates to {@see self::fromStatus()}, the single translation point.
fromStatus()  : AxiamException
The single translation point. When a live PSR-7 `$response` is available, pass it so a resulting {@see NetworkError} can build its redacted header summary via {@see NetworkError::fromResponse()}; otherwise a status-only {@see NetworkError} is built via {@see NetworkError::fromException()}.

Methods

fromOAuth2Response()

The `/oauth2/*` translation point (CONTRACT.md §12.3 rule 3): a `400` from `POST /oauth2/token`, or a `401` from `POST /oauth2/introspect` / `POST /oauth2/revoke`, carrying an `OAuth2ErrorResponse` body (`{error, error_description}`) MUST surface as {@see OAuthProtocolError} rather than the generic {@see self::fromStatus()} mapping (which would otherwise collapse a `400` into a plain {@see NetworkError}, or a `401` into a plain {@see AuthError} that would wrongly enter the §9 single-flight refresh guard, §12.3 rule 3).

public static fromOAuth2Response(ResponseInterface $response[, string $context = 'oauth2 request failed' ]) : AxiamException

Falls back to self::fromStatus() when the body does not look like an OAuth2ErrorResponse (missing/non-string error), so a genuinely malformed or unexpected error body from an /oauth2/* endpoint still gets a sensible mapping instead of a confusing OAuthProtocolError with an empty error field.

Parameters
$response : ResponseInterface
$context : string = 'oauth2 request failed'
Return values
AxiamException

fromResponse()

Convenience wrapper for callers that already hold a live PSR-7 response — delegates to {@see self::fromStatus()}, the single translation point.

public static fromResponse(ResponseInterface $response[, string $context = 'AXIAM API error' ]) : AxiamException
Parameters
$response : ResponseInterface
$context : string = 'AXIAM API error'
Return values
AxiamException

fromStatus()

The single translation point. When a live PSR-7 `$response` is available, pass it so a resulting {@see NetworkError} can build its redacted header summary via {@see NetworkError::fromResponse()}; otherwise a status-only {@see NetworkError} is built via {@see NetworkError::fromException()}.

public static fromStatus(int $status[, ResponseInterface|null $response = null ][, string $context = 'AXIAM API error' ]) : AxiamException
Parameters
$status : int
$response : ResponseInterface|null = null
$context : string = 'AXIAM API error'
Return values
AxiamException
On this page

Search results