Skip to content

Commit

Permalink
Move exception handling to filter
Browse files Browse the repository at this point in the history
  • Loading branch information
standeren committed Nov 28, 2023
1 parent 1206f0f commit 91818f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public override void OnException(ExceptionContext context)
{
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, GitErrorCodes.GiteaSessionExpired, HttpStatusCode.Unauthorized)) { StatusCode = (int)HttpStatusCode.Unauthorized };
}
if (context.Exception is LibGit2SharpException && context.Exception.Message.Contains("server requires authentication that we do not support"))
{
context.Result = new ObjectResult(ProblemDetailsUtils.GenerateProblemDetails(context.Exception, GitErrorCodes.GiteaSessionExpired, HttpStatusCode.Unauthorized)) { StatusCode = (int)HttpStatusCode.Unauthorized };
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,6 @@ public void FetchRemoteChanges(string org, string repository)
{
_decoratedService.FetchRemoteChanges(org, repository);
}
catch (LibGit2Sharp.LibGit2SharpException libGit2SharpException)
{
if (libGit2SharpException.Message.Contains("server requires authentication that we do not support"))
{
throw new GiteaUnathorizedException("Gitea session is invalid.");
}

throw;
}
catch (Exception ex)
{
LogError(ex, "FetchRemoteChanges", org, repository);
Expand Down

0 comments on commit 91818f3

Please sign in to comment.