X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FRemoteLibraryException.java;h=4cbb631cb3b0e916ae112b9148769e554c31ae93;hb=a67248cf983a1370625887c82ed7524e95b56dd1;hp=ff40960c58a4b24e93771c777f722e1378514e2b;hpb=22d93a38248927ade78968d06ea22390a1540962;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/RemoteLibraryException.java b/src/be/nikiroo/fanfix/library/RemoteLibraryException.java index ff40960..4cbb631 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibraryException.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibraryException.java @@ -10,6 +10,9 @@ import java.io.IOException; public class RemoteLibraryException extends IOException { private static final long serialVersionUID = 1L; + private boolean wrapped; + + @SuppressWarnings("unused") private RemoteLibraryException() { // for serialization purposes } @@ -18,14 +21,80 @@ public class RemoteLibraryException extends IOException { * Wrap an {@link IOException} to allow it to pass across the network. * * @param cause - * the excption to wrap + * the exception to wrap + * @param remote + * this exception is used to send the contained + * {@link IOException} to the other end of the network + */ + public RemoteLibraryException(IOException cause, boolean remote) { + this(null, cause, remote); + } + + /** + * Wrap an {@link IOException} to allow it to pass across the network. + * + * @param message + * the error message + * @param wrapped + * this exception is used to send the contained + * {@link IOException} to the other end of the network */ - public RemoteLibraryException(IOException cause) { - super(cause); + public RemoteLibraryException(String message, boolean wrapped) { + this(message, null, wrapped); } - @Override - public synchronized IOException getCause() { - return (IOException) super.getCause(); + /** + * Wrap an {@link IOException} to allow it to pass across the network. + * + * @param message + * the error message + * @param cause + * the exception to wrap + * @param wrapped + * this exception is used to send the contained + * {@link IOException} to the other end of the network + */ + public RemoteLibraryException(String message, IOException cause, + boolean wrapped) { + super(message, cause); + this.wrapped = wrapped; + } + + /** + * Return the actual exception we should return to the client code. It can + * be: + *
+ * In other words, do not use this exception in client code when it + * has reached the other end of the network, but use its cause instead (see + * {@link RemoteLibraryException#unwrapException()}). + * + * @return TRUE if it is + */ + public boolean isWrapped() { + return wrapped; } }