DeepL: improved error handling

This commit is contained in:
M66B 2021-05-19 16:34:52 +02:00
parent b7d7ad1674
commit 487b1038c0
1 changed files with 3 additions and 4 deletions

View File

@ -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());