
net.anthavio.httl.HttlException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hatatitla Show documentation
Show all versions of hatatitla Show documentation
Compact but tweakable REST client library you have been dreaming of
The newest version!
package net.anthavio.httl;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
/**
*
* @author martin.vanek
*
*/
public class HttlException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final Exception delegate;
protected HttlException(String message) {
super(message);
this.delegate = null;
}
public HttlException(Exception x) {
super(x);
this.delegate = x;
}
public Exception getException() {
return delegate;
}
/**
* If connect refused | connect timeout | read timeout
*/
public boolean isConnectOrReadTimeout() {
return delegate instanceof ConnectException || delegate instanceof SocketTimeoutException;
}
@Override
public void printStackTrace() {
if (delegate != null) {
System.out.println(this);
delegate.printStackTrace();
} else {
super.printStackTrace();
}
}
@Override
public void printStackTrace(PrintStream s) {
if (delegate != null) {
s.println(this);
delegate.printStackTrace(s);
} else {
super.printStackTrace(s);
}
}
@Override
public void printStackTrace(PrintWriter s) {
if (delegate != null) {
s.println(this);
delegate.printStackTrace(s);
} else {
super.printStackTrace(s);
}
}
@Override
public StackTraceElement[] getStackTrace() {
if (delegate != null) {
return delegate.getStackTrace();
} else {
return super.getStackTrace();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy