PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/horde/framework/Horde/Exception/Wrapped.php

https://bitbucket.org/moodle/moodle
PHP | 56 lines | 26 code | 2 blank | 28 comment | 4 complexity | 5c94ba6234ab26e67e7097dc971dc91a MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1, BSD-3-Clause, MIT, GPL-3.0
  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. * Horde exception class that can wrap and set its details from PEAR_Error,
  15. * Exception, and other objects with similar interfaces.
  16. *
  17. * @author
  18. * @category Horde
  19. * @copyright 2008-2017 Horde LLC
  20. * @license http://www.horde.org/licenses/lgpl21 LGPL
  21. * @package Exception
  22. */
  23. class Horde_Exception_Wrapped extends Horde_Exception
  24. {
  25. /**
  26. * Exception constructor.
  27. *
  28. * @param mixed $message The exception message, a PEAR_Error
  29. * object, or an Exception object.
  30. * @param int $code A numeric error code.
  31. */
  32. public function __construct($message = null, $code = 0)
  33. {
  34. $previous = null;
  35. if (is_object($message) &&
  36. method_exists($message, 'getMessage')) {
  37. if (empty($code) &&
  38. method_exists($message, 'getCode')) {
  39. $code = (int)$message->getCode();
  40. }
  41. if ($message instanceof Exception) {
  42. $previous = $message;
  43. }
  44. if (method_exists($message, 'getUserinfo') &&
  45. $details = $message->getUserinfo()) {
  46. $this->details = $details;
  47. } elseif (!empty($message->details)) {
  48. $this->details = $message->details;
  49. }
  50. $message = (string)$message->getMessage();
  51. }
  52. parent::__construct($message, $code, $previous);
  53. }
  54. }