Requests Exception Hierarchy
Exception classes for the Requests library.
Source files:
wp-includes/Requests/src/Exception.phpwp-includes/Requests/src/Exception/InvalidArgument.phpwp-includes/Requests/src/Exception/ArgumentCount.phpwp-includes/Requests/src/Exception/Transport.phpwp-includes/Requests/src/Exception/Transport/Curl.php
Class Hierarchy
PHPException
├── WpOrgRequestsException
│ ├── WpOrgRequestsExceptionArgumentCount (final)
│ ├── WpOrgRequestsExceptionTransport
│ │ └── WpOrgRequestsExceptionTransportCurl (final)
│ └── WpOrgRequestsExceptionHttp (see class-requests-exception-http.md)
│
PHPInvalidArgumentException
└── WpOrgRequestsExceptionInvalidArgument (final)WpOrgRequestsException
Base exception for all Requests errors.
Namespace: WpOrgRequests
Package: RequestsExceptions
Extends: Exception
Properties
| Property | Type | Visibility | Description |
|---|---|---|---|
$type | string | protected | String error type code |
$data | mixed | protected | Associated data |
Methods
__construct()
public function __construct( string $message, string $type, mixed $data = null, int $code = 0 )| Parameter | Type | Description |
|---|---|---|
$message | string | Human-readable error message |
$type | string | String error type identifier |
$data | mixed | Associated data |
$code | int | Numerical error code |
getType()
public function getType(): stringReturns the string type code (similar to getCode() but a string).
getData()
public function getData(): mixedReturns associated data.
WpOrgRequestsExceptionInvalidArgument
Exception for invalid argument types.
Namespace: WpOrgRequestsException
Package: RequestsExceptions
Since: 2.0.0
Modifier: final
Extends: InvalidArgumentException
Methods
create()
Factory method producing a standardized error message.
public static function create( int $position, string $name, string $expected, string $received ): InvalidArgument| Parameter | Type | Description |
|---|---|---|
$position | int | Argument position (1-based) |
$name | string | Argument name (e.g., '$host') |
$expected | string | Expected type(s) as string |
$received | string | Actual type received |
Message format: ClassName::methodName(): Argument #1 ($name) must be of type expected, received given
Uses debug_backtrace() to determine the calling class and method.
WpOrgRequestsExceptionArgumentCount
Exception for incorrect number of arguments or array elements.
Namespace: WpOrgRequestsException
Package: RequestsExceptions
Since: 2.0.0
Modifier: final
Extends: WpOrgRequestsException
Methods
create()
Factory method producing a standardized error message.
public static function create( string $expected, int $received, string $type ): ArgumentCount| Parameter | Type | Description |
|---|---|---|
$expected | string | Expected count as phrase (e.g., 'an array with exactly two elements') |
$received | int | Actual count |
$type | string | Exception type string for the parent Exception |
Message format: ClassName::methodName() expects expected, received given
Uses debug_backtrace() to determine the calling class and method.
WpOrgRequestsExceptionTransport
Base transport exception.
Namespace: WpOrgRequestsException
Package: RequestsExceptions
Extends: WpOrgRequestsException
Empty class — serves as a base type for transport-specific exceptions.
WpOrgRequestsExceptionTransportCurl
cURL-specific transport exception.
Namespace: WpOrgRequestsExceptionTransport
Package: RequestsExceptions
Modifier: final
Extends: WpOrgRequestsExceptionTransport
Constants
| Constant | Value | Description |
|---|---|---|
EASY | 'cURLEasy' | cURL easy handle error |
MULTI | 'cURLMulti' | cURL multi handle error |
SHARE | 'cURLShare' | cURL share handle error |
Properties
| Property | Type | Default | Description |
|---|---|---|---|
$code | int | -1 | cURL error code |
$type | string | 'Unknown' | Error type: EASY, MULTI, or SHARE |
$reason | string | 'Unknown' | Clear text error message |
Methods
__construct()
public function __construct( string $message, string $type, mixed $data = null, int $code = 0 )Sets $type, $code, and $reason from parameters (if non-null). Formats the parent message as "{code} {reason}".
getReason()
public function getReason(): stringReturns the clear text error message.