Skip to content

Commit

Permalink
Add fix for access denied from security class (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
greggbjensen authored Aug 23, 2024
1 parent 8fbfe78 commit 110c925
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion prdeploy-api/src/PrDeploy.Api/Filters/SanitizedErrorFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public IError OnError(IError error)
var result = error;
switch (error.Exception)
{
// GitHub not found is a forbidden.
case Octokit.NotFoundException:
// GitHub not found is a forbidden.
result = ErrorBuilder.FromError(error)
.SetCode("FORBIDDEN")
.SetMessage("Access denied.")
Expand All @@ -28,6 +28,20 @@ public IError OnError(IError error)
null, HttpStatusCode.Forbidden))
.Build();
break;

case HttpRequestException requestException:
if (requestException.StatusCode == HttpStatusCode.Forbidden)
{
result = ErrorBuilder.FromError(error)
.SetCode("FORBIDDEN")
.SetMessage("Access denied.")
.SetException(
new HttpRequestException("Access denied.",
null, HttpStatusCode.Forbidden))
.Build();
}
break;

}

_logger.LogError(error.Exception, error.Message, error);
Expand Down

0 comments on commit 110c925

Please sign in to comment.