Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  namespace enrol_lti\local\ltiadvantage\lib;
  18  
  19  use Packback\Lti1p3\Interfaces\IHttpException;
  20  use Packback\Lti1p3\Interfaces\IHttpResponse;
  21  
  22  /**
  23   * An implementation of IHTTPException, for use with the lib/lti1p3 library code.
  24   *
  25   * @package    enrol_lti
  26   * @copyright  2022 Jake Dallimore <jrhdallimore@gmail.com>
  27   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  28   */
  29  class http_exception extends \Exception implements IHttpException {
  30  
  31      /** @var IHttpResponse the response to which this exception relates.*/
  32      protected $response;
  33  
  34      /**
  35       * Constructor.
  36       *
  37       * @param IHttpResponse $response a response instance.
  38       * @param string $message
  39       * @param int $code
  40       * @param \Throwable|null $previous
  41       */
  42      public function __construct(IHttpResponse $response, $message = "", $code = 0, \Throwable $previous = null) {
  43  
  44          parent::__construct($message, $code, $previous);
  45          $this->response = $response;
  46      }
  47  
  48      /**
  49       * Get the http response.
  50       *
  51       * @return IHttpResponse the response.
  52       */
  53      public function getResponse(): IHttpResponse {
  54          return $this->response;
  55      }
  56  }