AppleNewsException
extends Exception
in package
Base exception class for all errors returned by the Apple News API.
This class parses the standardized error format returned by Apple and provides access to specific API error codes and key paths (field names).
Table of Contents
Properties
- $errorCode : string|null
- $keyPath : string|null
Methods
- __construct() : mixed
- fromResponse() : self
- Factory method to create an exception from a standard API error response.
- getErrorCode() : string|null
- Get the specific Apple News API error code (e.g., INVALID_REVISION).
- getKeyPath() : string|null
- Get the path to the field that failed validation.
Properties
$errorCode
protected
string|null
$errorCode
= null
The specific Apple News API error code.
$keyPath
protected
string|null
$keyPath
= null
The field path in the request that caused the error.
Methods
__construct()
public
__construct([string $message = '' ][, int $code = 0 ][, Throwable|null $previous = null ][, string|null $errorCode = null ][, string|null $keyPath = null ]) : mixed
Parameters
- $message : string = ''
-
Exception message.
- $code : int = 0
-
HTTP status code.
- $previous : Throwable|null = null
-
Previous exception.
- $errorCode : string|null = null
-
API-specific error code.
- $keyPath : string|null = null
-
Field path where error occurred.
fromResponse()
Factory method to create an exception from a standard API error response.
public
static fromResponse(array<string, mixed> $response[, int $httpCode = 0 ]) : self
Parameters
- $response : array<string, mixed>
-
Decoded JSON error response.
- $httpCode : int = 0
-
HTTP status code from the response.
Return values
selfgetErrorCode()
Get the specific Apple News API error code (e.g., INVALID_REVISION).
public
getErrorCode() : string|null
Return values
string|nullgetKeyPath()
Get the path to the field that failed validation.
public
getKeyPath() : string|null