aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Sproxy/Application.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Sproxy/Application.hs b/src/Sproxy/Application.hs
index 5de9474..3d6598f 100644
--- a/src/Sproxy/Application.hs
+++ b/src/Sproxy/Application.hs
@@ -30,8 +30,8 @@ import Network.HTTP.Conduit (requestBodySourceChunkedIO, requestBodySourceIO)
import Network.HTTP.Types (RequestHeaders, ResponseHeaders, methodGet, methodPost)
import Network.HTTP.Types.Header ( hConnection,
hContentLength, hContentType, hCookie, hLocation, hTransferEncoding )
-import Network.HTTP.Types.Status ( Status(..), badRequest400, forbidden403, found302,
- internalServerError500, methodNotAllowed405, movedPermanently301,
+import Network.HTTP.Types.Status ( Status(..), badGateway502, badRequest400, forbidden403,
+ found302, internalServerError500, methodNotAllowed405, movedPermanently301,
networkAuthenticationRequired511, notFound404, ok200, seeOther303, temporaryRedirect307 )
import Network.Socket (NameInfoFlag(NI_NUMERICHOST), getNameInfo)
import Network.Wai.Conduit (sourceRequestBody, responseSource)
@@ -383,12 +383,16 @@ notFound msg req resp = do
logException :: W.Middleware
logException app req resp =
catches (app req resp) [
+ Handler badGateway,
Handler internalError
]
where
internalError :: SomeException -> IO W.ResponseReceived
internalError = response internalServerError500
+ badGateway :: BE.HttpException -> IO W.ResponseReceived
+ badGateway = response badGateway502
+
response :: Exception e => Status -> e -> IO W.ResponseReceived
response st e = do
Log.error $ show (statusCode st) ++ " " ++ unpack (statusMessage st)