WooCommerce Code Reference

ApiException extends RuntimeException
in package

Exception for API errors with error codes and extensions.

Table of Contents

__construct()  : mixed
Constructor.
getErrorCode()  : string
Get the machine-readable error code.
getExtensions()  : array<string|int, mixed>
Get the additional error metadata.
getStatusCode()  : int
Get the HTTP status code.

Methods

__construct()

Constructor.

public __construct(string $message[, string $error_code = 'INTERNAL_ERROR' ][, array<string|int, mixed> $extensions = array() ][, int $status_code = 500 ][, Throwable|null $previous = null ]) : mixed
Parameters
$message : string

The error message.

$error_code : string = 'INTERNAL_ERROR'

The machine-readable error code.

$extensions : array<string|int, mixed> = array()

Additional error metadata.

$status_code : int = 500

The HTTP status code.

$previous : Throwable|null = null

The previous throwable for chaining.

Return values
mixed

getErrorCode()

Get the machine-readable error code.

public getErrorCode() : string
Return values
string

getExtensions()

Get the additional error metadata.

public getExtensions() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStatusCode()

Get the HTTP status code.

public getStatusCode() : int
Return values
int