DeepL: improved error handling

pull/199/head
M66B 3 years ago
parent b7d7ad1674
commit 487b1038c0

@ -65,14 +65,13 @@ public class DeepL {
int status = connection.getResponseCode();
if (status != HttpsURLConnection.HTTP_OK) {
String error;
String error = "Error " + status + ": " + connection.getResponseMessage();
try {
error = Helper.readStream(connection.getErrorStream());
error += "\n" + Helper.readStream(connection.getErrorStream());
} catch (Throwable ex) {
Log.w(ex);
error = ex.getMessage();
}
throw new FileNotFoundException("Error " + status + ": " + error);
throw new FileNotFoundException(error);
}
String response = Helper.readStream(connection.getInputStream());

Loading…
Cancel
Save