Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  
   3  namespace GuzzleHttp\Exception;
   4  
   5  use Psr\Http\Message\RequestInterface;
   6  use Psr\Http\Message\ResponseInterface;
   7  
   8  /**
   9   * Exception when an HTTP error occurs (4xx or 5xx error)
  10   */
  11  class BadResponseException extends RequestException
  12  {
  13      public function __construct(
  14          string $message,
  15          RequestInterface $request,
  16          ResponseInterface $response,
  17          \Throwable $previous = null,
  18          array $handlerContext = []
  19      ) {
  20          parent::__construct($message, $request, $response, $previous, $handlerContext);
  21      }
  22  
  23      /**
  24       * Current exception and the ones that extend it will always have a response.
  25       */
  26      public function hasResponse(): bool
  27      {
  28          return true;
  29      }
  30  
  31      /**
  32       * This function narrows the return type from the parent class and does not allow it to be nullable.
  33       */
  34      public function getResponse(): ResponseInterface
  35      {
  36          /** @var ResponseInterface */
  37          return parent::getResponse();
  38      }
  39  }