|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
15
|
|
|
* |
|
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
17
|
|
|
* and is licensed under the LGPL. For more information please see |
|
18
|
|
|
* <http://phing.info>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace Phing\Exception; |
|
22
|
|
|
|
|
23
|
|
|
use Exception; |
|
24
|
|
|
use Phing\Parser\Location; |
|
25
|
|
|
use RuntimeException; |
|
26
|
|
|
use Throwable; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* BuildException is for when things go wrong in a build execution. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Andreas Aderhold <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class BuildException extends RuntimeException |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Location in the xml file. |
|
37
|
|
|
* |
|
38
|
|
|
* @var Location |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $location; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Construct a BuildException. |
|
44
|
|
|
* Supported signatures: |
|
45
|
|
|
* throw new BuildException($causeExc); |
|
46
|
|
|
* throw new BuildException($msg); |
|
47
|
|
|
* throw new Buildexception($causeExc, $loc); |
|
48
|
|
|
* throw new BuildException($msg, $causeExc); |
|
49
|
|
|
* throw new BuildException($msg, $loc); |
|
50
|
|
|
* throw new BuildException($msg, $causeExc, $loc);. |
|
51
|
|
|
* |
|
52
|
|
|
* @param Exception|string $p1 |
|
53
|
|
|
* @param null|Exception|Location $p2 |
|
54
|
|
|
* @param null|Location $p3 |
|
55
|
|
|
*/ |
|
56
|
251 |
|
public function __construct($p1 = '', $p2 = null, $p3 = null) |
|
57
|
|
|
{ |
|
58
|
251 |
|
$cause = null; |
|
59
|
251 |
|
$loc = null; |
|
60
|
251 |
|
$msg = ''; |
|
61
|
|
|
|
|
62
|
251 |
|
if (null !== $p3) { |
|
63
|
4 |
|
if ($p2 instanceof Throwable) { |
|
64
|
4 |
|
$cause = $p2; |
|
65
|
|
|
} |
|
66
|
4 |
|
$loc = $p3; |
|
67
|
4 |
|
$msg = $p1; |
|
68
|
250 |
|
} elseif (null !== $p2) { |
|
69
|
41 |
|
if ($p2 instanceof Throwable) { |
|
70
|
28 |
|
$cause = $p2; |
|
71
|
28 |
|
$msg = $p1; |
|
72
|
15 |
|
} elseif ($p2 instanceof Location) { |
|
|
|
|
|
|
73
|
14 |
|
$loc = $p2; |
|
74
|
14 |
|
if ($p1 instanceof Throwable) { |
|
75
|
|
|
$cause = $p1; |
|
76
|
|
|
} else { |
|
77
|
14 |
|
$msg = $p1; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
229 |
|
} elseif ($p1 instanceof Throwable) { |
|
81
|
15 |
|
$cause = $p1; |
|
82
|
15 |
|
$msg = $p1->getMessage(); |
|
83
|
|
|
} else { |
|
84
|
216 |
|
$msg = (string) $p1; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
251 |
|
if (null !== $loc) { |
|
88
|
16 |
|
$this->setLocation($loc); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
251 |
|
parent::__construct($msg, 0, $cause); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
2 |
|
public function __toString() |
|
95
|
|
|
{ |
|
96
|
2 |
|
return (string) $this->location . ' ' . $this->getMessage(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Gets the location of error in XML file. |
|
101
|
|
|
* |
|
102
|
|
|
* @return Location |
|
103
|
|
|
*/ |
|
104
|
173 |
|
public function getLocation() |
|
105
|
|
|
{ |
|
106
|
173 |
|
return $this->location; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Sets the location of error in XML file. |
|
111
|
|
|
*/ |
|
112
|
185 |
|
public function setLocation(Location $loc) |
|
113
|
|
|
{ |
|
114
|
185 |
|
$this->location = $loc; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|