diff --git a/docs/features/errorcodes.rst b/docs/features/errorcodes.rst
new file mode 100644
index 00000000..fe058790
--- /dev/null
+++ b/docs/features/errorcodes.rst
@@ -0,0 +1,13 @@
+Http Error Status Codes
+=======================
+
+Ocelot will return HTTP status error codes based on internal logic in certain siturations:
+- 401 if the authentication middleware runs and the user is not authenticated.
+- 403 if the authorisation middleware runs and the user is unauthenticated, claim value not authroised, scope not authorised, user doesnt have required claim or cannot find claim.
+- 503 if the downstream request times out.
+- 499 if the request is cancelled by the client.
+- 404 if unable to find a downstream route.
+- 502 if unable to connect to downstream service.
+- 500 if unable to complete the HTTP request downstream and the exception is not OperationCanceledException or HttpRequestException.
+- 404 if Ocelot is unable to map an internal error code to a HTTP status code.
+
diff --git a/docs/index.rst b/docs/index.rst
index 7952c91a..1acbd712 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -42,6 +42,7 @@ Thanks for taking a look at the Ocelot documentation. Please use the left hand n
features/loadbalancer
features/delegatinghandlers
features/raft
+ features/errorcodes
.. toctree::
:maxdepth: 2
diff --git a/src/Ocelot/Requester/ConnectionToDownstreamServiceError.cs b/src/Ocelot/Requester/ConnectionToDownstreamServiceError.cs
index d2087983..6c03863c 100644
--- a/src/Ocelot/Requester/ConnectionToDownstreamServiceError.cs
+++ b/src/Ocelot/Requester/ConnectionToDownstreamServiceError.cs
@@ -3,7 +3,7 @@ using System;
namespace Ocelot.Requester
{
- class ConnectionToDownstreamServiceError : Error
+ public class ConnectionToDownstreamServiceError : Error
{
public ConnectionToDownstreamServiceError(Exception exception)
: base($"Error connecting to downstream service, exception: {exception}", OcelotErrorCode.ConnectionToDownstreamServiceError)
diff --git a/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs b/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
index f696a02b..a86fcf37 100644
--- a/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
+++ b/src/Ocelot/Requester/HttpExeptionToErrorMapper.cs
@@ -5,7 +5,6 @@ namespace Ocelot.Requester
using System;
using System.Collections.Generic;
using System.Net.Http;
- using System.Net.Sockets;
public class HttpExeptionToErrorMapper : IExceptionToErrorMapper
{
diff --git a/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs b/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
index 26da864f..be1b2f66 100644
--- a/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
+++ b/src/Ocelot/Responder/IErrorsToHttpStatusCodeMapper.cs
@@ -1,8 +1,9 @@
-using Ocelot.Errors;
-using System.Collections.Generic;
+namespace Ocelot.Responder
+{
+ using System.Net;
+ using Ocelot.Errors;
+ using System.Collections.Generic;
-namespace Ocelot.Responder
-{
///
/// Map a list OceoltErrors to a single appropriate HTTP status code
///
diff --git a/test/Ocelot.UnitTests/Requester/HttpExeptionToErrorMapperTests.cs b/test/Ocelot.UnitTests/Requester/HttpExeptionToErrorMapperTests.cs
index 14413aad..a05ccec0 100644
--- a/test/Ocelot.UnitTests/Requester/HttpExeptionToErrorMapperTests.cs
+++ b/test/Ocelot.UnitTests/Requester/HttpExeptionToErrorMapperTests.cs
@@ -7,6 +7,7 @@
using Shouldly;
using System;
using System.Collections.Generic;
+ using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
@@ -38,6 +39,14 @@
error.ShouldBeOfType();
}
+ [Fact]
+ public void should_return_ConnectionToDownstreamServiceError()
+ {
+ var error = _mapper.Map(new HttpRequestException());
+
+ error.ShouldBeOfType();
+ }
+
[Fact]
public void should_return_request_canceled_for_subtype()
{