1 |
/* WriteAbortedException.java -- An exception occurred while writing a |
/* WriteAbortedException.java -- wraps an exception thrown while writing |
2 |
serialization stream |
Copyright (C) 1998, 2000, 2002 Free Software Foundation, Inc. |
|
Copyright (C) 1998, 2000 Free Software Foundation, Inc. |
|
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 2, or (at your option) |
the Free Software Foundation; either version 2, or (at your option) |
9 |
any later version. |
any later version. |
10 |
|
|
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
GNU Classpath is distributed in the hope that it will be useful, but |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
39 |
package java.io; |
package java.io; |
40 |
|
|
41 |
/** |
/** |
42 |
* This exception is thrown when one of the other ObjectStreamException |
* This exception is thrown when another ObjectStreamException occurs during |
43 |
* subclasses was thrown during a serialization write. |
* a serialization read or write. The stream is reset, and deserialized |
44 |
* |
* objects are discarded. |
|
* @version 0.0 |
|
45 |
* |
* |
46 |
* @author Aaron M. Renn (arenn@urbanophile.com) |
* @author Aaron M. Renn (arenn@urbanophile.com) |
47 |
|
* @author Eric Blake <ebb9@email.byu.edu> |
48 |
|
* @since 1.1 |
49 |
|
* @status updated to 1.4 |
50 |
*/ |
*/ |
51 |
public class WriteAbortedException extends ObjectStreamException |
public class WriteAbortedException extends ObjectStreamException |
52 |
{ |
{ |
53 |
|
/** |
54 |
/* |
* Compatible with JDK 1.1+. |
55 |
* Instance Variables |
*/ |
56 |
*/ |
private static final long serialVersionUID = -3326426625597282442L; |
57 |
|
|
58 |
/** |
/** |
59 |
* The detailed exception that caused this exception to be thrown |
* The cause of this exception. This pre-dates the exception chaining |
60 |
*/ |
* of Throwable; and although you can change this field, you are wiser |
61 |
public Exception detail; |
* to leave it alone. |
62 |
private transient String message; |
* |
63 |
|
* @serial the exception cause |
64 |
/*************************************************************************/ |
*/ |
65 |
|
public Exception detail; |
66 |
/* |
|
67 |
* Constructors |
/** |
68 |
*/ |
* Create a new WriteAbortedException with a specified message and |
69 |
|
* cause. |
70 |
/** |
* |
71 |
* Create a new WriteAbortedException with an eof parameter indicating |
* @param msg the message |
72 |
* the detailed Exception that caused this exception to be thrown. |
* @param detail the cause |
73 |
* |
*/ |
74 |
* @param detail The exception that caused this exception to be thrown |
public WriteAbortedException(String msg, Exception detail) |
75 |
*/ |
{ |
76 |
public |
super(msg); |
77 |
WriteAbortedException(String msg, Exception detail) |
initCause(detail); |
78 |
{ |
this.detail = detail; |
79 |
this.message = msg; |
} |
80 |
this.detail = detail; |
|
81 |
} |
/** |
82 |
|
* This method returns a message indicating what went wrong, in this |
83 |
/*************************************************************************/ |
* format: |
84 |
|
* <code>super.getMessage() + (detail == null ? "" : "; " + detail)<code>. |
85 |
/* |
* |
86 |
* Instance Variables |
* @return the chained message |
87 |
*/ |
*/ |
88 |
|
public String getMessage() |
89 |
/** |
{ |
90 |
* This method returns a message indicating what went wrong, including |
if (detail == this || detail == null) |
91 |
* the message text from the initial exception that caused this one to |
return super.getMessage(); |
92 |
* be thrown |
return super.getMessage() + "; " + detail; |
93 |
*/ |
} |
94 |
public String |
|
95 |
getMessage() |
/** |
96 |
{ |
* Returns the cause of this exception. Note that this may not be the |
97 |
return(message + ": " + detail.getMessage()); |
* original cause, thanks to the <code>detail</code> field being public |
98 |
} |
* and non-final (yuck). However, to avoid violating the contract of |
99 |
|
* Throwable.getCause(), this returns null if <code>detail == this</code>, |
100 |
|
* as no exception can be its own cause. |
101 |
|
* |
102 |
|
* @return the cause |
103 |
|
* @since 1.4 |
104 |
|
*/ |
105 |
|
public Throwable getCause() |
106 |
|
{ |
107 |
|
return detail == this ? null : detail; |
108 |
|
} |
109 |
} // class WriteAbortedException |
} // class WriteAbortedException |
|
|
|