root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / compiler / CompilerException.java @ 15280
History | View | Annotate | Download (4.61 KB)
1 |
/*
|
---|---|
2 |
* $Id: CompilerException.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2001,2002 Marcus Stursberg
|
5 |
*
|
6 |
* File : CompilerException.java
|
7 |
* Description : Indicate an error while compiling the installer.
|
8 |
* Author's email : marcus@emsty.de
|
9 |
* Author's Website : http://www.emasty.de
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 |
*/
|
25 |
package com.izforge.izpack.compiler; |
26 |
|
27 |
/**
|
28 |
* Indicates a Failure to compile.
|
29 |
*
|
30 |
* @author Marcus Stursberg
|
31 |
*/
|
32 |
public class CompilerException extends java.io.IOException |
33 |
{ |
34 |
/**
|
35 |
* The throwable that caused this throwable to get thrown, or null if this
|
36 |
* throwable was not caused by another throwable, or if the causative
|
37 |
* throwable is unknown. If this field is equal to this throwable itself,
|
38 |
* it indicates that the cause of this throwable has not yet been
|
39 |
* initialized.
|
40 |
*/
|
41 |
private Throwable _cause = this; |
42 |
|
43 |
/**
|
44 |
* Construct a new exception with the specified message.
|
45 |
*
|
46 |
* @param message Description of the error
|
47 |
*/
|
48 |
public CompilerException(String message) |
49 |
{ |
50 |
super(message);
|
51 |
} |
52 |
|
53 |
/**
|
54 |
* Construct a new exception with the specified message and wraps another
|
55 |
* cause.
|
56 |
*
|
57 |
* @param message Description of the error
|
58 |
* @param cause Throwable
|
59 |
*/
|
60 |
public CompilerException(String message, Throwable cause) |
61 |
{ |
62 |
super(message);
|
63 |
this._cause = cause;
|
64 |
} |
65 |
|
66 |
/**
|
67 |
* Initializes the <i>cause</i> of this throwable to the specified value.
|
68 |
* (The cause is the throwable that caused this throwable to get thrown.)
|
69 |
*
|
70 |
* <p>This method can be called at most once. It is generally called from
|
71 |
* within the constructor, or immediately after creating the throwable. If
|
72 |
* this throwable was created with {@link
|
73 |
* #CompilerException(String,Throwable)}, this method cannot be called even
|
74 |
* once.
|
75 |
*
|
76 |
* @param cause the cause (which is saved for later retrieval by the
|
77 |
* {@link #getCause()} method). (A <code>null</code> value is
|
78 |
* permitted, and indicates that the cause is nonexistent or
|
79 |
* unknown.)
|
80 |
* @return a reference to this <code>Throwable</code> instance.
|
81 |
* @throws IllegalArgumentException if <code>cause</code> is this
|
82 |
* throwable. (A throwable cannot be its own cause.)
|
83 |
* @throws IllegalStateException if this throwable was created with {@link
|
84 |
* #CompilerException(String,Throwable)}, or this method has already
|
85 |
* been called on this throwable.
|
86 |
*/
|
87 |
public synchronized Throwable initCause(Throwable cause) |
88 |
{ |
89 |
if (this._cause != this) |
90 |
throw new IllegalStateException("Can't overwrite cause"); |
91 |
if (cause == this) |
92 |
throw new IllegalArgumentException("Self-causation not permitted"); |
93 |
this._cause = cause;
|
94 |
return this; |
95 |
} |
96 |
|
97 |
/**
|
98 |
* Returns the cause of this throwable or <code>null</code> if the
|
99 |
* cause is nonexistent or unknown. (The cause is the throwable that
|
100 |
* caused this throwable to get thrown.)
|
101 |
*
|
102 |
* <p>This implementation returns the cause that was supplied via one of the
|
103 |
* constructors requiring a <code>Throwable</code>, or that was set after
|
104 |
* creation with the {@link #initCause(Throwable)} method. While it is
|
105 |
* typically unnecessary to override this method, a subclass can override it
|
106 |
* to return a cause set by some other means. This is appropriate for a
|
107 |
* "legacy chained throwable" that predates the addition of chained
|
108 |
* exceptions to <code>Throwable</code>. Note that it is <i>not</i>
|
109 |
* necessary to override any of the <code>PrintStackTrace</code> methods, all
|
110 |
* of which invoke the <code>getCause</code> method to determine the cause of
|
111 |
* a throwable.
|
112 |
*
|
113 |
* @return the cause of this throwable or <code>null</code> if the
|
114 |
* cause is nonexistent or unknown.
|
115 |
*/
|
116 |
public Throwable getCause() |
117 |
{ |
118 |
return (_cause==this ? null : _cause); |
119 |
} |
120 |
} |