Check for null error streams

This commit is contained in:
M66B
2021-08-14 09:23:01 +02:00
parent ce3f3dd387
commit 60c9d33a65
2 changed files with 12 additions and 6 deletions

View File

@@ -215,7 +215,9 @@ public class DeepL {
if (status != HttpsURLConnection.HTTP_OK) {
String error = "Error " + status + ": " + connection.getResponseMessage();
try {
error += "\n" + Helper.readStream(connection.getErrorStream());
InputStream is = connection.getErrorStream();
if (is != null)
error += "\n" + Helper.readStream(is);
} catch (Throwable ex) {
Log.w(ex);
}
@@ -257,7 +259,9 @@ public class DeepL {
if (status != HttpsURLConnection.HTTP_OK) {
String error = "Error " + status + ": " + connection.getResponseMessage();
try {
error += "\n" + Helper.readStream(connection.getErrorStream());
InputStream is = connection.getErrorStream();
if (is != null)
error += "\n" + Helper.readStream(is);
} catch (Throwable ex) {
Log.w(ex);
}