[http] Throw FileNotFoundException on 404
This commit is contained in:
parent
97d86d35be
commit
96499ca1e3
|
@ -2,9 +2,7 @@ package io.gitlab.jfronny.commons;
|
|||
|
||||
import io.gitlab.jfronny.commons.serialize.Serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.*;
|
||||
import java.net.http.HttpClient;
|
||||
|
@ -160,6 +158,7 @@ public class HttpUtils {
|
|||
}
|
||||
return _send(accept, responseBodyHandler);
|
||||
}
|
||||
if (res.statusCode() == 404) throw new FileNotFoundException("Didn't find anything under that url (URL=" + url + ")");
|
||||
throw new IOException("Unexpected return method: " + res.statusCode() + " (URL=" + url + ")");
|
||||
}
|
||||
|
||||
|
@ -216,4 +215,8 @@ public class HttpUtils {
|
|||
public static Request delete(String url) throws URISyntaxException {
|
||||
return new Request(Method.DELETE, url);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws URISyntaxException, IOException {
|
||||
get("https://frohnmeyer-wds.de/doesnt_exxist").send();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user