mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 01:42:18 +00:00
Throw a different exception type for unexpected http status codes
This commit is contained in:
parent
0c5a84c305
commit
b1fdf380f9
@ -65,8 +65,7 @@ public abstract class AbstractJsonList<T, E extends Exception> {
|
||||
}
|
||||
|
||||
protected void handleResponseError() throws E, IOException, ServalDInterfaceException {
|
||||
throw new ServalDFailureException("received unexpected HTTP Status "+
|
||||
httpConnection.getResponseCode()+" " + httpConnection.getResponseMessage()+" from " + httpConnection.getURL());
|
||||
throw new ServalDUnexpectedHttpStatus(httpConnection);
|
||||
}
|
||||
|
||||
public void connect() throws IOException, ServalDInterfaceException, E {
|
||||
|
@ -0,0 +1,18 @@
|
||||
package org.servalproject.servaldna;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class ServalDUnexpectedHttpStatus extends ServalDInterfaceException {
|
||||
public final int responseCode;
|
||||
public final String responseMessage;
|
||||
public final URL url;
|
||||
public ServalDUnexpectedHttpStatus(HttpURLConnection httpConnection) throws IOException {
|
||||
super("received unexpected HTTP Status "+
|
||||
httpConnection.getResponseCode()+" " + httpConnection.getResponseMessage()+" from " + httpConnection.getURL());
|
||||
this.responseCode = httpConnection.getResponseCode();
|
||||
this.responseMessage = httpConnection.getResponseMessage();
|
||||
this.url = httpConnection.getURL();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user