01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.io;
19:
20: /**
21: * This type of exception is thrown by readObject() when it detects an exception
22: * marker in the input stream. This marker indicates that when the object was
23: * being serialized, an exception happened and this marker was inserted instead
24: * of the original object. It is a way to "propagate" an exception from the code
25: * that attempted to write the object to the code that is attempting to read the
26: * object.
27: *
28: * @see ObjectInputStream#readObject()
29: */
30: public class WriteAbortedException extends ObjectStreamException {
31:
32: private static final long serialVersionUID = -3326426625597282442L;
33:
34: /**
35: * The exception that was caused when writeObject() was attempting to
36: * serialize the object
37: */
38: public Exception detail;
39:
40: /**
41: * Constructs a new instance of this class with its walkback, message and
42: * the exception which caused the underlying problem when serializing the
43: * object filled in.
44: *
45: * @param detailMessage
46: * the detail message for the exception.
47: * @param rootCause
48: * exception that caused the problem when serializing the object.
49: */
50: public WriteAbortedException(String detailMessage,
51: Exception rootCause) {
52: super (detailMessage);
53: detail = rootCause;
54: initCause(rootCause);
55: }
56:
57: /**
58: * Answers the extra information message which was provided when the
59: * throwable was created. If no message was provided at creation time, then
60: * answer null.
61: *
62: * @return the receiver's message.
63: */
64: @Override
65: public String getMessage() {
66: String msg = super .getMessage();
67: if (detail != null) {
68: msg = msg + "; " + detail.toString(); //$NON-NLS-1$
69: }
70: return msg;
71: }
72:
73: /**
74: * Answers the cause of this Throwable, or null if there is no cause.
75: *
76: * @return the receiver's cause.
77: */
78: @Override
79: public Throwable getCause() {
80: return detail;
81: }
82: }
|