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  /**
   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 can wrap and set its details from PEAR_Error,
  16   * Exception, and other objects with similar interfaces.
  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_Wrapped extends Horde_Exception
  25  {
  26      /**
  27       * Exception constructor.
  28       *
  29       * @param mixed $message The exception message, a PEAR_Error
  30       *                       object, or an Exception object.
  31       * @param int   $code    A numeric error code.
  32       */
  33      public function __construct($message = null, $code = 0)
  34      {
  35          $previous = null;
  36          if (is_object($message) &&
  37              method_exists($message, 'getMessage')) {
  38              if (empty($code) &&
  39                  method_exists($message, 'getCode')) {
  40                  $code = (int)$message->getCode();
  41              }
  42              if ($message instanceof Exception) {
  43                  $previous = $message;
  44              }
  45              if (method_exists($message, 'getUserinfo') &&
  46                  $details = $message->getUserinfo()) {
  47                  $this->details = $details;
  48              } elseif (!empty($message->details)) {
  49                  $this->details = $message->details;
  50              }
  51              $message = (string)$message->getMessage();
  52          }
  53  
  54          parent::__construct($message, $code, $previous);
  55      }
  56  }