Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.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  }