Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

   1  <?php
   2  /**
   3   * Copyright 2008-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @author   
   9   * @category Horde
  10   * @license  http://www.horde.org/licenses/lgpl21 LGPL
  11   * @package  Exception
  12   */
  13  
  14  /**
  15   * Horde exception class that accepts output of error_get_last() as $code and
  16   * mask itself as that error.
  17   *
  18   * @author    
  19   * @category  Horde
  20   * @copyright 2008-2017 Horde LLC
  21   * @license   http://www.horde.org/licenses/lgpl21 LGPL
  22   * @package   Exception
  23   */
  24  class Horde_Exception_LastError extends Horde_Exception
  25  {
  26      /**
  27       * Exception constructor
  28       *
  29       * If $lasterror is passed the return value of error_get_last() (or a
  30       * matching format), the exception will be rewritten to have its file and
  31       * line parameters match that of the array, and any message in the array
  32       * will be appended to $message.
  33       *
  34       * @param mixed $message             The exception message, a PEAR_Error
  35       *                                   object, or an Exception object.
  36       * @param mixed $code_or_lasterror   Either a numeric error code, or
  37       *                                   an array from error_get_last().
  38       */
  39      public function __construct($message = null, $code_or_lasterror = null)
  40      {
  41          if (is_array($code_or_lasterror)) {
  42              if ($message) {
  43                  $message .= $code_or_lasterror['message'];
  44              } else {
  45                  $message = $code_or_lasterror['message'];
  46              }
  47              parent::__construct($message, $code_or_lasterror['type']);
  48              $this->file = $code_or_lasterror['file'];
  49              $this->line = $code_or_lasterror['line'];
  50          } else {
  51              parent::__construct($message, $code_or_lasterror ?? 0);
  52          }
  53      }
  54  
  55  }