Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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