Requests_Exception_HTTP::get_class() WordPress Method

The Requests_Exception_HTTP::get_class() method is used to get the class of an HTTP exception. This is useful for catching specific errors when dealing with the Requests library.

Requests_Exception_HTTP::get_class( int|bool $code ) #

Get the correct exception class for a given error code


Parameters

$code

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


Top ↑

Return

(string) Exception class name to use


Top ↑

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';
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.