View file vendor/illuminate/http/Client/RequestException.php

File size: 0.98Kb
  1. <?php
  2.  
  3. namespace Illuminate\Http\Client;
  4.  
  5. class RequestException extends HttpClientException
  6. {
  7. /**
  8. * The response instance.
  9. *
  10. * @var \Illuminate\Http\Client\Response
  11. */
  12. public $response;
  13.  
  14. /**
  15. * Create a new exception instance.
  16. *
  17. * @param \Illuminate\Http\Client\Response $response
  18. * @return void
  19. */
  20. public function __construct(Response $response)
  21. {
  22. parent::__construct($this->prepareMessage($response), $response->status());
  23.  
  24. $this->response = $response;
  25. }
  26.  
  27. /**
  28. * Prepare the exception message.
  29. *
  30. * @param \Illuminate\Http\Client\Response $response
  31. * @return string
  32. */
  33. protected function prepareMessage(Response $response)
  34. {
  35. $message = "HTTP request returned status code {$response->status()}";
  36.  
  37. $summary = \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());
  38.  
  39. return is_null($summary) ? $message : $message .= ":\n{$summary}\n";
  40. }
  41. }