mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-03 15:50:52 +00:00
Adding suggested exception from @PauloMigAlmeida
When the OTP code is requested, then the special GHOTPRequiredException is raised instead of the generic IOException. This differentiates between an OTP request and a failed password.
This commit is contained in:
@@ -758,8 +758,11 @@ class Requester {
|
||||
IOUtils.closeQuietly(es);
|
||||
}
|
||||
}
|
||||
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 / Unauthorized == bad creds
|
||||
throw e;
|
||||
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 Unauthorized == bad creds
|
||||
if(uc.getHeaderField("X-GitHub-OTP") != null)
|
||||
throw (IOException) new GHOTPRequiredException().withResponseHeaderFields(uc).initCause(e);
|
||||
else
|
||||
throw e; // usually org.kohsuke.github.HttpException (which extends IOException)
|
||||
|
||||
if ("0".equals(uc.getHeaderField("X-RateLimit-Remaining"))) {
|
||||
root.rateLimitHandler.onError(e,uc);
|
||||
|
||||
Reference in New Issue
Block a user