Requests_Exception_HTTP::get_class

Advertisement

Summery Summery

Get the correct exception class for a given error code

Syntax Syntax

Requests_Exception_HTTP::get_class( int|bool $code )

Parameters Parameters

$code

(int|bool) (Required) HTTP status code, or false if unavailable

Return Return

(string) Exception class name to use

Source Source

File: wp-includes/Requests/Exception/HTTP.php

	public static function get_class($code) {
		if (!$code) {
			return 'Requests_Exception_HTTP_Unknown';
		}

		$class = sprintf('Requests_Exception_HTTP_%d', $code);
		if (class_exists($class)) {
			return $class;
		}

		return 'Requests_Exception_HTTP_Unknown';
	}

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.