Skip to main content
Taliup\Sdk\Exceptions\ApiException is thrown for every error that occurs inside the Taliup PHP SDK — including failed API requests, connection timeouts, invalid webhook signatures, and bad configuration. It extends PHP’s built-in RuntimeException, so you can catch it alongside other runtime errors or on its own.

Constructor

You will not typically construct ApiException yourself — the SDK throws it for you. The constructor signature is documented here for completeness and for use in testing or custom error handling.
string
required
Human-readable description of the error.
int
required
HTTP status code associated with the error. Pass 0 for errors that occurred before any HTTP response was received (e.g. connection timeouts, missing credentials).
array
Decoded response body from the API. Defaults to [] when no response body is available.

Methods

getMessage(): string

Inherited from RuntimeException. Returns a human-readable description of the error, sourced from the API message field when available.

getStatusCode(): int

Returns the HTTP status code associated with the error.
Returns 0 for errors that occurred before an HTTP response was received — for example, a connection timeout or a missing credential detected client-side.

getResponseBody(): array

Returns the raw decoded response body from the API as an associative array. Useful for inspecting validation errors or additional context returned by the server.
Returns an empty array [] when no response body is available (such as connection errors or client-side validation failures).

Common status codes

Example

For webhook errors, Webhook::constructEvent() throws ApiException with status 401 for an invalid signature and 400 for a non-JSON payload. See the Webhook reference for a full example.