123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- class BuildException extends Exception {
-
- protected $location;
-
-
- protected $cause;
-
-
- function __construct($p1, $p2 = null, $p3 = null) {
-
- $cause = null;
- $loc = null;
- $msg = "";
-
- if ($p3 !== null) {
- $cause = $p2;
- $loc = $p3;
- $msg = $p1;
- } elseif ($p2 !== null) {
- if ($p2 instanceof Exception) {
- $cause = $p2;
- $msg = $p1;
- } elseif ($p2 instanceof Location) {
- $loc = $p2;
- if ($p1 instanceof Exception) {
- $cause = $p1;
- } else {
- $msg = $p1;
- }
- }
- } elseif ($p1 instanceof Exception) {
- $cause = $p1;
- } else {
- $msg = $p1;
- }
-
- parent::__construct($msg);
-
- if ($cause !== null) {
- $this->cause = $cause;
- $this->message .= " [wrapped: " . $cause->getMessage() ."]";
- }
-
- if ($loc !== null) {
- $this->setLocation($loc);
- }
- }
-
-
- public function getCause() {
- return $this->cause;
- }
-
-
- public function getLocation() {
- return $this->location;
- }
-
- public function setLocation(Location $loc) {
- $this->location = $loc;
- $this->message = $loc->toString() . ': ' . $this->message;
- }
- }
|