diff --git a/Web/Scotty/Action.hs b/Web/Scotty/Action.hs index f625d6c..0f6afcc 100644 --- a/Web/Scotty/Action.hs +++ b/Web/Scotty/Action.hs @@ -111,9 +111,9 @@ runAction :: MonadUnliftIO m => -> m (Maybe Response) runAction mh env action = do ok <- flip runReaderT env $ runAM $ tryNext $ action `catches` concat - [ [actionErrorHandler] + [ [actionErrorHandler, statusErrorHandler, scottyExceptionHandler] , maybeToList mh - , [statusErrorHandler, scottyExceptionHandler, someExceptionHandler] + , [someExceptionHandler] ] res <- getResponse env return $ bool Nothing (Just $ mkResponse res) ok diff --git a/test/Web/ScottySpec.hs b/test/Web/ScottySpec.hs index fcbe860..0476cc6 100644 --- a/test/Web/ScottySpec.hs +++ b/test/Web/ScottySpec.hs @@ -65,7 +65,7 @@ spec = do makeRequest "/:paramName" `shouldRespondWith` ":paramName" it ("captures route parameters for " ++ method ++ " requests with url encoded '/' in path") $ do makeRequest "/a%2Fb" `shouldRespondWith` "a/b" - + describe "addroute" $ do forM_ availableMethods $ \method -> do withApp (addroute method "/scotty" $ html "") $ do @@ -108,9 +108,13 @@ spec = do withApp (do let h = Handler (\(_ :: E.SomeException) -> setHeader "Location" "/c" >> status status500) defaultHandler h - Scotty.get "/a" (redirect "/b")) $ do + Scotty.get "/a" (redirect "/b") + Scotty.get "/d" (raiseStatus status404 "d not found")) $ do it "should give priority to actionErrorHandlers" $ do get "/a" `shouldRespondWith` 302 { matchHeaders = ["Location" <:> "/b"] } + get "/d" + `shouldRespondWith` + "