1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

SMACK-465: XMPPException using Java's wrapped Throwable

This commit is contained in:
Georg Lukas 2013-11-11 09:33:31 +01:00
parent 602a8fc812
commit fea2db2be7

View file

@ -20,9 +20,6 @@ package org.jivesoftware.smack;
import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smack.packet.XMPPError;
import java.io.PrintStream;
import java.io.PrintWriter;
/**
* A generic exception that is thrown when an error occurs performing an
* XMPP operation. XMPP servers can respond to error conditions with an error code
@ -42,7 +39,6 @@ public class XMPPException extends Exception {
private StreamError streamError = null;
private XMPPError error = null;
private Throwable wrappedThrowable = null;
private SmackError smackError = null;
/**
@ -78,8 +74,7 @@ public class XMPPException extends Exception {
* @param wrappedThrowable the root cause of the exception.
*/
public XMPPException(Throwable wrappedThrowable) {
super();
this.wrappedThrowable = wrappedThrowable;
super(wrappedThrowable);
}
/**
@ -113,8 +108,7 @@ public class XMPPException extends Exception {
* @param wrappedThrowable the root cause of the exception.
*/
public XMPPException(String message, Throwable wrappedThrowable) {
super(message);
this.wrappedThrowable = wrappedThrowable;
super(message, wrappedThrowable);
}
/**
@ -126,9 +120,8 @@ public class XMPPException extends Exception {
* @param wrappedThrowable the root cause of the exception.
*/
public XMPPException(String message, XMPPError error, Throwable wrappedThrowable) {
super(message);
super(message, wrappedThrowable);
this.error = error;
this.wrappedThrowable = wrappedThrowable;
}
/**
@ -176,32 +169,13 @@ public class XMPPException extends Exception {
/**
* Returns the Throwable asscociated with this exception, or <tt>null</tt> if there
* isn't one.
* isn't one. @deprecated, use Exception.getCause() instead.
*
* @return the Throwable asscociated with this exception.
*/
@Deprecated
public Throwable getWrappedThrowable() {
return wrappedThrowable;
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream out) {
super.printStackTrace(out);
if (wrappedThrowable != null) {
out.println("Nested Exception: ");
wrappedThrowable.printStackTrace(out);
}
}
public void printStackTrace(PrintWriter out) {
super.printStackTrace(out);
if (wrappedThrowable != null) {
out.println("Nested Exception: ");
wrappedThrowable.printStackTrace(out);
}
return getCause();
}
public String getMessage() {
@ -229,8 +203,8 @@ public class XMPPException extends Exception {
if (streamError != null) {
buf.append(streamError);
}
if (wrappedThrowable != null) {
buf.append("\n -- caused by: ").append(wrappedThrowable);
if (getCause() != null) {
buf.append("\n -- caused by: ").append(getCause());
}
return buf.toString();