HorizonRequestException
extends ErrorException
in package
Exception thrown when a Horizon API request fails
This exception encapsulates all information about a failed Horizon request, including the HTTP status code, error response details, and rate limiting information. It extends ErrorException to provide detailed error context.
Rate limiting (HTTP 429) responses include a retry-after value that indicates when the request can be retried.
Tags
Table of Contents
Properties
- $httpResponse : ResponseInterface|null
Methods
- __construct() : mixed
- HorizonRequestException constructor
- fromOtherException() : HorizonRequestException
- Creates a HorizonRequestException from another exception
- getHorizonErrorResponse() : HorizonErrorResponse|null
- Gets the structured Horizon error response
- getHttpMethod() : string
- Gets the HTTP method used to request the URL
- getHttpResponse() : ResponseInterface|null
- Gets the raw HTTP response
- getRequestedUrl() : string
- Gets the URL that was requested and generated the error
- getRetryAfter() : string|null
- Gets the retry-after value for rate-limited requests
- getStatusCode() : int|null
- Gets the HTTP status code of the failed request
Properties
$httpResponse
public
ResponseInterface|null
$httpResponse
= null
Methods
__construct()
HorizonRequestException constructor
public
__construct(string $title[, Throwable|null $previous = null ]) : mixed
Parameters
- $title : string
-
The error message title
- $previous : Throwable|null = null
-
The previous exception for exception chaining
fromOtherException()
Creates a HorizonRequestException from another exception
public
static fromOtherException(string $requestedUrl, string $httpMethod, Exception $e[, ResponseInterface|null $httpResponse = null ]) : HorizonRequestException
This factory method wraps other exceptions (particularly Guzzle exceptions) into a HorizonRequestException with additional context about the request.
Parameters
- $requestedUrl : string
-
The URL that was requested
- $httpMethod : string
-
The HTTP method used
- $e : Exception
-
The original exception
- $httpResponse : ResponseInterface|null = null
-
The HTTP response, if available
Return values
HorizonRequestException —The wrapped exception
getHorizonErrorResponse()
Gets the structured Horizon error response
public
getHorizonErrorResponse() : HorizonErrorResponse|null
Return values
HorizonErrorResponse|null —The parsed Horizon error response, or null if not available
getHttpMethod()
Gets the HTTP method used to request the URL
public
getHttpMethod() : string
Return values
string —The HTTP method (GET, POST, etc.)
getHttpResponse()
Gets the raw HTTP response
public
getHttpResponse() : ResponseInterface|null
Return values
ResponseInterface|null —The PSR-7 HTTP response, or null if not available
getRequestedUrl()
Gets the URL that was requested and generated the error
public
getRequestedUrl() : string
Return values
string —The requested URL
getRetryAfter()
Gets the retry-after value for rate-limited requests
public
getRetryAfter() : string|null
When a request is rate-limited (HTTP 429), this indicates how many seconds to wait before retrying the request.
Return values
string|null —The retry-after value (in seconds), or null if not rate-limited
getStatusCode()
Gets the HTTP status code of the failed request
public
getStatusCode() : int|null
Return values
int|null —The HTTP status code, or null if not available