YoastSEO_Vendor\GuzzleHttp
Middleware::httpErrors() public Yoast 1.0
Middleware that throws exceptions for 4xx or 5xx responses when the "http_error" request option is set to true.
{} Это метод класса: Middleware{}
Хуков нет.
Возвращает
callable. Returns a function that accepts the next handler.
Использование
$result = Middleware::httpErrors();
Код Middleware::httpErrors() Middleware::httpErrors Yoast 15.6.2
public static function httpErrors()
{
return function (callable $handler) {
return function ($request, array $options) use($handler) {
if (empty($options['http_errors'])) {
return $handler($request, $options);
}
return $handler($request, $options)->then(function (\YoastSEO_Vendor\Psr\Http\Message\ResponseInterface $response) use($request, $handler) {
$code = $response->getStatusCode();
if ($code < 400) {
return $response;
}
throw \YoastSEO_Vendor\GuzzleHttp\Exception\RequestException::create($request, $response);
});
};
};
}