mirror of https://github.com/M66B/FairEmail.git
Handle GitHib errors
This commit is contained in:
parent
5d681e56aa
commit
30272777ad
|
@ -744,6 +744,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
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"}
|
||||
JSONObject jmessage = new JSONObject(response.toString());
|
||||
if (jmessage.has("message"))
|
||||
throw new IllegalArgumentException(jmessage.getString("message"));
|
||||
throw new IOException("HTTP " + status + ": " + response.toString());
|
||||
}
|
||||
if (status != HttpsURLConnection.HTTP_OK)
|
||||
throw new IOException("HTTP " + status + ": " + response.toString());
|
||||
|
||||
|
@ -808,6 +815,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
if (args.getBoolean("always"))
|
||||
if (ex instanceof IllegalArgumentException)
|
||||
Snackbar.make(getVisibleView(), ex.getMessage(), Snackbar.LENGTH_LONG).show();
|
||||
else
|
||||
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
|
||||
}
|
||||
}.execute(this, args, "update:check");
|
||||
|
|
Loading…
Reference in New Issue