Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   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);
  52          }
  53      }
  54  
  55  }