Requests_Exception_HTTP::__construct() WordPress Method

The Requests_Exception_HTTP::__construct() method is used to construct an HTTP exception. This exception is thrown when an HTTP status code is returned that is not 200.

Requests_Exception_HTTP::__construct( string|null $reason = null, mixed $data = null ) #

Create a new exception


Description

There is no mechanism to pass in the status code, as this is set by the subclass used. Reason phrases can vary, however.


Top ↑

Parameters

$reason

(string|null)(Optional)Reason phrase

Default value: null

$data

(mixed)(Optional)Associated data

Default value: null


Top ↑

Source

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

	public function __construct($reason = null, $data = null) {
		if ($reason !== null) {
			$this->reason = $reason;
		}

		$message = sprintf('%d %s', $this->code, $this->reason);
		parent::__construct($message, 'httpresponse', $data, $this->code);
	}

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.