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

ThreeMammals / Ocelot / 28241800735

26 Jun 2026 01:40PM UTC coverage: 96.77% (-0.04%) from 96.813%
28241800735

Pull #2406

github

web-flow
Merge 15093915b into 6062d5a5a
Pull Request #2406: #2403 Add `SecurityOptions` support to the WebSocket pipeline

6561 of 6780 relevant lines covered (96.77%)

2634.85 hits per line

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

90.0
src/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
    {
39✔
10
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthenticatedError))
39✔
11
        {
2✔
12
            return StatusCodes.Status401Unauthorized;
2✔
13
        }
14

15
        if (errors.Any(e => e.Code == OcelotErrorCode.UnauthorizedError
37✔
16
            || e.Code == OcelotErrorCode.ClaimValueNotAuthorizedError
37✔
17
            || e.Code == OcelotErrorCode.ScopeNotAuthorizedError
37✔
18
            || e.Code == OcelotErrorCode.UserDoesNotHaveClaimError
37✔
19
            || e.Code == OcelotErrorCode.CannotFindClaimError
37✔
20
            || e.Code == OcelotErrorCode.SecurityError))
37✔
21
        {
7✔
22
            return StatusCodes.Status403Forbidden;
7✔
23
        }
24

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

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

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

43
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToFindDownstreamRouteError))
28✔
44
        {
1✔
45
            return StatusCodes.Status404NotFound;
1✔
46
        }
47

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

53
        if (errors.Any(e => e.Code == OcelotErrorCode.UnableToCompleteRequestError
26✔
54
            || e.Code == OcelotErrorCode.CouldNotFindLoadBalancerCreator
26✔
55
            || e.Code == OcelotErrorCode.ErrorInvokingLoadBalancerCreator))
26✔
56
        {
3✔
57
            return StatusCodes.Status500InternalServerError;
3✔
58
        }
59

60
        if (errors.Any(e => e.Code == OcelotErrorCode.PayloadTooLargeError))
23✔
61
        {
1✔
62
            return StatusCodes.Status413PayloadTooLarge;
1✔
63
        }
64

65
        if (errors.Any(e => e.Code == OcelotErrorCode.BadRequestError))
22✔
66
        {
1✔
67
            return StatusCodes.Status400BadRequest;
1✔
68
        }
69

70
        return StatusCodes.Status404NotFound;
21✔
71
    }
39✔
72
}
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