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