• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ThreeMammals / Ocelot / 23302213965

19 Mar 2026 03:19PM UTC coverage: 91.219% (-1.3%) from 92.49%
23302213965

Pull #2369

github

web-flow
Merge 7f6f01146 into 086c7b15c
Pull Request #2369: Pre-Release 25.0 aka Beta 2

8404 of 9213 relevant lines covered (91.22%)

2131.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
src/Ocelot/Responder/ErrorsToHttpStatusCodeMapper.cs
1
using Microsoft.AspNetCore.Http;
2
using Ocelot.Errors;
3

4
namespace Ocelot.Responder;
5

6
public class ErrorsToHttpStatusCodeMapper : IErrorsToHttpStatusCodeMapper
7
{
8
    public int Map(List<Error> errors)
9
    {
37✔
10
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthenticatedError))
79✔
11
        {
2✔
12
            return 401;
2✔
13
        }
14

15
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthorizedError
72✔
16
            || e.Code == OcelotErrorCode.ClaimValueNotAuthorizedError
72✔
17
            || e.Code == OcelotErrorCode.ScopeNotAuthorizedError
72✔
18
            || e.Code == OcelotErrorCode.UserDoesNotHaveClaimError
72✔
19
            || e.Code == OcelotErrorCode.CannotFindClaimError))
72✔
20
        {
6✔
21
            return 403;
6✔
22
        }
23

24
        if (errors.Any(e => e.Code == OcelotErrorCode.QuotaExceededError))
59✔
25
        {
×
26
            return errors.Single(e => e.Code == OcelotErrorCode.QuotaExceededError).HttpStatusCode;
×
27
        }
28

29
        if (errors.Any(e => e.Code == OcelotErrorCode.RequestTimedOutError))
59✔
30
        {
2✔
31
            return StatusCodes.Status503ServiceUnavailable;
2✔
32
        }
33

34
        if (errors.Any(e => e.Code == OcelotErrorCode.RequestCanceled))
54✔
35
        {
×
36
            // status code refer to
37
            // https://stackoverflow.com/questions/46234679/what-is-the-correct-http-status-code-for-a-cancelled-request?answertab=votes#tab-top
38
            // https://httpstatuses.com/499
39
            return StatusCodes.Status499ClientClosedRequest;
×
40
        }
41

42
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToFindDownstreamRouteError))
54✔
43
        {
1✔
44
            return 404;
1✔
45
        }
46

47
        if (errors.Any(e => e.Code == OcelotErrorCode.ConnectionToDownstreamServiceError))
52✔
48
        {
1✔
49
            return 502;
1✔
50
        }
51

52
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToCompleteRequestError
50✔
53
            || e.Code == OcelotErrorCode.CouldNotFindLoadBalancerCreator
50✔
54
            || e.Code == OcelotErrorCode.ErrorInvokingLoadBalancerCreator))
50✔
55
        {
3✔
56
            return 500;
3✔
57
        }
58

59
        if (errors.Any(e => e.Code == OcelotErrorCode.PayloadTooLargeError))
44✔
60
        {
1✔
61
            return 413;
1✔
62
        }
63

64
        return 404;
21✔
65
    }
37✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc