Throws an exception if the request was not successful
Parameters
$allow_redirects
booleanoptional- Set to false to throw on a 3xx as well
Default:
true
Source
public function throw_for_status($allow_redirects = true) {
if ($this->is_redirect()) {
if ($allow_redirects !== true) {
throw new Exception('Redirection not allowed', 'response.no_redirects', $this);
}
} elseif (!$this->success) {
$exception = Http::get_class($this->status_code);
throw new $exception(null, $this);
}
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.