-
Notifications
You must be signed in to change notification settings - Fork 10.9k
/
RequestException.php
43 lines (35 loc) · 1015 Bytes
/
RequestException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Illuminate\Http\Client;
use GuzzleHttp\Psr7\Message;
class RequestException extends HttpClientException
{
/**
* The response instance.
*
* @var \Illuminate\Http\Client\Response
*/
public $response;
/**
* Create a new exception instance.
*
* @param \Illuminate\Http\Client\Response $response
* @return void
*/
public function __construct(Response $response)
{
parent::__construct($this->prepareMessage($response), $response->status());
$this->response = $response;
}
/**
* Prepare the exception message.
*
* @param \Illuminate\Http\Client\Response $response
* @return string
*/
protected function prepareMessage(Response $response)
{
$message = "HTTP request returned status code {$response->status()}";
$summary = Message::bodySummary($response->toPsrResponse());
return is_null($summary) ? $message : $message .= ":\n{$summary}\n";
}
}