MarketData SDK

ApiException extends MarketDataException
in package

ApiException class

This exception is thrown when an API error occurs (business logic errors like "no data found" or invalid symbol). It extends the base MarketDataException class and provides access to request context for debugging and support.

Table of Contents

Properties

$requestId  : string|null
$requestUrl  : string|null
$response  : ResponseInterface|null
$timestamp  : DateTimeImmutable

Methods

__construct()  : mixed
ApiException constructor.
__toString()  : string
Get string representation of the exception.
getRequestId()  : string|null
Get the Cloudflare request ID for support tickets.
getRequestUrl()  : string|null
Get the URL that was requested when the error occurred.
getResponse()  : ResponseInterface|null
Get the HTTP response associated with this exception.
getSupportContext()  : array<string|int, mixed>
Get all support ticket context as an associative array.
getSupportInfo()  : string
Get a pre-formatted string with all information needed for a support ticket.
getTimestamp()  : DateTimeImmutable
Get the timestamp when the exception occurred.
extractRequestId()  : string|null
Extract the request ID (cf-ray header) from the response.

Properties

$requestId

protected string|null $requestId

The Cloudflare request ID (cf-ray header) for support tickets.

$requestUrl

protected string|null $requestUrl

The URL that was requested when the error occurred.

$response

protected ResponseInterface|null $response

The HTTP response associated with this exception.

$timestamp

protected DateTimeImmutable $timestamp

The timestamp when the exception occurred (stored in UTC).

Methods

__construct()

ApiException constructor.

public __construct(string $message[, int $code = 0 ][, Throwable|null $previous = null ][, ResponseInterface|null $response = null ][, string|null $requestUrl = null ]) : mixed
Parameters
$message : string

The exception message.

$code : int = 0

The exception code.

$previous : Throwable|null = null

The previous exception used for exception chaining.

$response : ResponseInterface|null = null

The HTTP response associated with this exception.

$requestUrl : string|null = null

The URL that was requested when the error occurred.

__toString()

Get string representation of the exception.

public __toString() : string

Includes the standard exception information plus request context (timestamp, request ID, and URL) when available.

Return values
string

getRequestId()

Get the Cloudflare request ID for support tickets.

public getRequestId() : string|null

This ID can be provided to Market Data support to help identify the specific request that failed.

Return values
string|null

The request ID, or null if not available.

getRequestUrl()

Get the URL that was requested when the error occurred.

public getRequestUrl() : string|null
Return values
string|null

The request URL, or null if not available.

getResponse()

Get the HTTP response associated with this exception.

public getResponse() : ResponseInterface|null
Return values
ResponseInterface|null

The HTTP response.

getSupportContext()

Get all support ticket context as an associative array.

public getSupportContext() : array<string|int, mixed>

Get support context as an associative array.

Return values
array<string|int, mixed>

getSupportInfo()

Get a pre-formatted string with all information needed for a support ticket.

public getSupportInfo() : string

Get pre-formatted support ticket information.

Return values
string

getTimestamp()

Get the timestamp when the exception occurred.

public getTimestamp() : DateTimeImmutable

The timestamp is stored in UTC. Convert to your preferred timezone as needed:

$localTime = $e->getTimestamp()->setTimezone(new \DateTimeZone('America/Los_Angeles'));
Return values
DateTimeImmutable

The timestamp when the exception was created (UTC).

extractRequestId()

Extract the request ID (cf-ray header) from the response.

protected extractRequestId(ResponseInterface|null $response) : string|null
Parameters
$response : ResponseInterface|null

The HTTP response.

Return values
string|null

The request ID, or null if not available.


        
On this page

Search results