PropelException.php 934 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * The base class of all exceptions thrown by Propel.
  11. * @author Hans Lellelid <hans@xmpl.org>
  12. * @version $Revision: 1612 $
  13. * @package propel.runtime.exception
  14. */
  15. class PropelException extends Exception {
  16. /** The nested "cause" exception. */
  17. protected $cause;
  18. function __construct($p1, $p2 = null) {
  19. $cause = null;
  20. if ($p2 !== null) {
  21. $msg = $p1;
  22. $cause = $p2;
  23. } else {
  24. if ($p1 instanceof Exception) {
  25. $msg = "";
  26. $cause = $p1;
  27. } else {
  28. $msg = $p1;
  29. }
  30. }
  31. parent::__construct($msg);
  32. if ($cause !== null) {
  33. $this->cause = $cause;
  34. $this->message .= " [wrapped: " . $cause->getMessage() ."]";
  35. }
  36. }
  37. function getCause() {
  38. return $this->cause;
  39. }
  40. }