Http::get_class( int|bool $code ): string

In this article

Get the correct exception class for a given error code


HTTP status code, or false if unavailable


string Exception class name to use


public static function get_class($code) {
	if (!$code) {
		return StatusUnknown::class;

	$class = sprintf('\WpOrg\Requests\Exception\Http\Status%d', $code);
	if (class_exists($class)) {
		return $class;

	return StatusUnknown::class;

User Contributed Notes

You must log in before being able to contribute a note or feedback.