| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
namespace phing; |
|---|
| 23 |
use phing::parser::Location; |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
class BuildException extends Exception { |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
* Location in the xml file. |
|---|
| 36 |
* @var Location |
|---|
| 37 |
*/ |
|---|
| 38 |
protected $location; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* The nested "cause" exception. |
|---|
| 42 |
* @var Exception |
|---|
| 43 |
*/ |
|---|
| 44 |
protected $cause; |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
* Construct a BuildException. |
|---|
| 48 |
* Supported signatures: |
|---|
| 49 |
* throw new BuildException($causeExc); |
|---|
| 50 |
* throw new BuildException($msg); |
|---|
| 51 |
* throw new Buildexception($causeExc, $loc); |
|---|
| 52 |
* throw new BuildException($msg, $causeExc); |
|---|
| 53 |
* throw new BuildException($msg, $loc); |
|---|
| 54 |
* throw new BuildException($msg, $causeExc, $loc); |
|---|
| 55 |
*/ |
|---|
| 56 |
function __construct($p1, $p2 = null, $p3 = null) { |
|---|
| 57 |
|
|---|
| 58 |
$cause = null; |
|---|
| 59 |
$loc = null; |
|---|
| 60 |
$msg = ""; |
|---|
| 61 |
|
|---|
| 62 |
if ($p3 !== null) { |
|---|
| 63 |
$cause = $p2; |
|---|
| 64 |
$loc = $p3; |
|---|
| 65 |
$msg = $p1; |
|---|
| 66 |
} elseif ($p2 !== null) { |
|---|
| 67 |
if ($p2 instanceof Exception) { |
|---|
| 68 |
$cause = $p2; |
|---|
| 69 |
$msg = $p1; |
|---|
| 70 |
} elseif ($p2 instanceof Location) { |
|---|
| 71 |
$loc = $p2; |
|---|
| 72 |
if ($p1 instanceof Exception) { |
|---|
| 73 |
$cause = $p1; |
|---|
| 74 |
} else { |
|---|
| 75 |
$msg = $p1; |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
} elseif ($p1 instanceof Exception) { |
|---|
| 79 |
$cause = $p1; |
|---|
| 80 |
} else { |
|---|
| 81 |
$msg = $p1; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
parent::__construct($msg); |
|---|
| 85 |
|
|---|
| 86 |
if ($cause !== null) { |
|---|
| 87 |
$this->cause = $cause; |
|---|
| 88 |
$this->message .= " [wrapped: " . $cause->getMessage() ."]"; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
if ($loc !== null) { |
|---|
| 92 |
$this->setLocation($loc); |
|---|
| 93 |
} |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
* Gets the cause exception. |
|---|
| 98 |
* |
|---|
| 99 |
* @return Exception |
|---|
| 100 |
*/ |
|---|
| 101 |
public function getCause() { |
|---|
| 102 |
return $this->cause; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
* Gets the location of error in XML file. |
|---|
| 107 |
* |
|---|
| 108 |
* @return Location |
|---|
| 109 |
*/ |
|---|
| 110 |
public function getLocation() { |
|---|
| 111 |
return $this->location; |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
* Sets the location of error in XML file. |
|---|
| 116 |
* |
|---|
| 117 |
* @param Locaiton $loc |
|---|
| 118 |
*/ |
|---|
| 119 |
public function setLocation(Location $loc) { |
|---|
| 120 |
$this->location = $loc; |
|---|
| 121 |
$this->message = $loc->toString() . ': ' . $this->message; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
} |
|---|
| 125 |
|
|---|