jaroslav@601: /* jaroslav@601: * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. jaroslav@601: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@601: * jaroslav@601: * This code is free software; you can redistribute it and/or modify it jaroslav@601: * under the terms of the GNU General Public License version 2 only, as jaroslav@601: * published by the Free Software Foundation. Oracle designates this jaroslav@601: * particular file as subject to the "Classpath" exception as provided jaroslav@601: * by Oracle in the LICENSE file that accompanied this code. jaroslav@601: * jaroslav@601: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@601: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@601: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@601: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@601: * accompanied this code). jaroslav@601: * jaroslav@601: * You should have received a copy of the GNU General Public License version jaroslav@601: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@601: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@601: * jaroslav@601: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@601: * or visit www.oracle.com if you need additional information or have any jaroslav@601: * questions. jaroslav@601: */ jaroslav@601: jaroslav@601: package java.io; jaroslav@601: jaroslav@601: /** jaroslav@601: * Signals that one of the ObjectStreamExceptions was thrown during a jaroslav@601: * write operation. Thrown during a read operation when one of the jaroslav@601: * ObjectStreamExceptions was thrown during a write operation. The jaroslav@601: * exception that terminated the write can be found in the detail jaroslav@601: * field. The stream is reset to it's initial state and all references jaroslav@601: * to objects already deserialized are discarded. jaroslav@601: * jaroslav@601: *

As of release 1.4, this exception has been retrofitted to conform to jaroslav@601: * the general purpose exception-chaining mechanism. The "exception causing jaroslav@601: * the abort" that is provided at construction time and jaroslav@601: * accessed via the public {@link #detail} field is now known as the jaroslav@601: * cause, and may be accessed via the {@link Throwable#getCause()} jaroslav@601: * method, as well as the aforementioned "legacy field." jaroslav@601: * jaroslav@601: * @author unascribed jaroslav@601: * @since JDK1.1 jaroslav@601: */ jaroslav@601: public class WriteAbortedException extends ObjectStreamException { jaroslav@601: private static final long serialVersionUID = -3326426625597282442L; jaroslav@601: jaroslav@601: /** jaroslav@601: * Exception that was caught while writing the ObjectStream. jaroslav@601: * jaroslav@601: *

This field predates the general-purpose exception chaining facility. jaroslav@601: * The {@link Throwable#getCause()} method is now the preferred means of jaroslav@601: * obtaining this information. jaroslav@601: * jaroslav@601: * @serial jaroslav@601: */ jaroslav@601: public Exception detail; jaroslav@601: jaroslav@601: /** jaroslav@601: * Constructs a WriteAbortedException with a string describing jaroslav@601: * the exception and the exception causing the abort. jaroslav@601: * @param s String describing the exception. jaroslav@601: * @param ex Exception causing the abort. jaroslav@601: */ jaroslav@601: public WriteAbortedException(String s, Exception ex) { jaroslav@601: super(s); jaroslav@601: initCause(null); // Disallow subsequent initCause jaroslav@601: detail = ex; jaroslav@601: } jaroslav@601: jaroslav@601: /** jaroslav@601: * Produce the message and include the message from the nested jaroslav@601: * exception, if there is one. jaroslav@601: */ jaroslav@601: public String getMessage() { jaroslav@601: if (detail == null) jaroslav@601: return super.getMessage(); jaroslav@601: else jaroslav@601: return super.getMessage() + "; " + detail.toString(); jaroslav@601: } jaroslav@601: jaroslav@601: /** jaroslav@601: * Returns the exception that terminated the operation (the cause). jaroslav@601: * jaroslav@601: * @return the exception that terminated the operation (the cause), jaroslav@601: * which may be null. jaroslav@601: * @since 1.4 jaroslav@601: */ jaroslav@601: public Throwable getCause() { jaroslav@601: return detail; jaroslav@601: } jaroslav@601: }