Check for null error streams

pull/203/head
M66B 4 years ago
parent ce3f3dd387
commit 60c9d33a65

@ -1218,11 +1218,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
InputStream inputStream = (status == HttpsURLConnection.HTTP_OK
? urlConnection.getInputStream() : urlConnection.getErrorStream());
if (inputStream != null) {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = br.readLine()) != null)
response.append(line);
}
if (status == HttpsURLConnection.HTTP_FORBIDDEN) {
// {"message":"API rate limit exceeded for ...","documentation_url":"https://developer.github.com/v3/#rate-limiting"}

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

Loading…
Cancel
Save