WP_CLI

RequestsLibrary::is_requests_exceptionpublic staticWP-CLI 1.0

Check if a given exception was issued by the Requests library.

This is used because we cannot easily catch multiple different exception classes with PHP 5.6. Because of that, we catch generic exceptions, check if they match the Requests library, and re-throw them if they do not.

Method of the class: RequestsLibrary{}

No Hooks.

Returns

true|false. Whether the provided exception was issued by the Requests library.

Usage

$result = RequestsLibrary::is_requests_exception( $exception );
$exception(Exception) (required)
Exception to check.

RequestsLibrary::is_requests_exception() code WP-CLI 2.13.0-alpha

public static function is_requests_exception( Exception $exception ) {
	return is_a( $exception, '\Requests_Exception' )
		|| is_a( $exception, '\WpOrg\Requests\Exception' );
}