Return failed dependency when random GitHub API exceptions occur

This commit is contained in:
Cyberboss
2018-09-19 14:50:47 -04:00
parent 1db1fc35b5
commit 3b9065061c
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -62,6 +62,7 @@ TGS will only every return the response codes listed here
- 409: Conflict. Documented in the requests that use them
- 410: Gone. Attempted to access/modify a resource that ideally should have been ready, but isn't or no longer is
- 422: Unprocessable Entity: Used specifically when an operation that requires a server restart is unable to be performed due to the @ref Tgstation.Server.Host.Watchdog not being present in the deployment. Blame MSO. Response body contains an @ref Tgstation.Server.Api.Models.ErrorMessage
- 424: Failed Dependency: When a request that depends on the GitHub API fails for a reason other than rate limiting. Check server logs, usually this indicates a bad access token.
- 426: Upgrade required: Used when the client's API version is not compatible with the server's. Response body contains an @ref Tgstation.Server.Api.Models.ErrorMessage
- 429: Rate limited. Used with operations that rely on GitHub.com. If a rate limit is hit for an operation this will be returned. Response will contain a Retry-After header
- 500: Server error. Please report the request and response body to the code repository
@@ -30,6 +30,8 @@ namespace Tgstation.Server.Host.Controllers
{
const string RestartNotSupportedException = "This deployment of tgstation-server is lacking the Tgstation.Server.Host.Watchdog component. Restarts and version changes cannot be completed!";
const string OctokitException = "Bad GitHub API response, check configuration! Exception: {0}";
/// <summary>
/// The <see cref="IGitHubClientFactory"/> for the <see cref="AdministrationController"/>
/// </summary>
@@ -128,6 +130,11 @@ namespace Tgstation.Server.Host.Controllers
{
return RateLimit(e);
}
catch (ApiException e)
{
Logger.LogWarning(OctokitException, e);
return StatusCode((int)HttpStatusCode.FailedDependency);
}
}
/// <inheritdoc />
@@ -154,6 +161,11 @@ namespace Tgstation.Server.Host.Controllers
{
return RateLimit(e);
}
catch (ApiException e)
{
Logger.LogWarning(OctokitException, e);
return StatusCode((int)HttpStatusCode.FailedDependency);
}
Logger.LogTrace("Release query complete!");
foreach (var release in releases)