1 package be
.nikiroo
.fanfix
.library
;
3 import java
.io
.IOException
;
6 * Exceptions sent from remote to local.
10 public class RemoteLibraryException
extends IOException
{
11 private static final long serialVersionUID
= 1L;
13 private boolean wrapped
;
15 @SuppressWarnings("unused")
16 private RemoteLibraryException() {
17 // for serialization purposes
21 * Wrap an {@link IOException} to allow it to pass across the network.
24 * the exception to wrap
26 * this exception is used to send the contained
27 * {@link IOException} to the other end of the network
29 public RemoteLibraryException(IOException cause
, boolean remote
) {
30 this(null, cause
, remote
);
34 * Wrap an {@link IOException} to allow it to pass across the network.
39 * this exception is used to send the contained
40 * {@link IOException} to the other end of the network
42 public RemoteLibraryException(String message
, boolean wrapped
) {
43 this(message
, null, wrapped
);
47 * Wrap an {@link IOException} to allow it to pass across the network.
52 * the exception to wrap
54 * this exception is used to send the contained
55 * {@link IOException} to the other end of the network
57 public RemoteLibraryException(String message
, IOException cause
,
59 super(message
, cause
);
60 this.wrapped
= wrapped
;
64 * Return the actual exception we should return to the client code. It can
67 * <li>the <tt>cause</tt> if {@link RemoteLibraryException#isWrapped()} is
69 * <li><tt>this</tt> if {@link RemoteLibraryException#isWrapped()} is FALSE
71 * <li><tt>this</tt> if the <tt>cause</tt> is NULL (so we never return NULL)
76 * @return the unwrapped exception or <tt>this</tt>, never NULL
78 public synchronized IOException
unwrapException() {
79 Throwable ex
= super.getCause();
80 if (!isWrapped() || !(ex
instanceof IOException
)) {
84 return (IOException
) ex
;
88 * This exception is used to send the contained {@link IOException} to the
89 * other end of the network.
91 * In other words, do not use <tt>this</tt> exception in client code when it
92 * has reached the other end of the network, but use its cause instead (see
93 * {@link RemoteLibraryException#unwrapException()}).
95 * @return TRUE if it is
97 public boolean isWrapped() {