Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for #237 #357

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

* add getResponseHeaders, getResponseStatus, getResponseContent (#214)
* add `captureParamMaybe`, `formParamMaybe`, `queryParamMaybe` (#322)
* deprecate `rescue` and `liftAndCatchIO`
* add `Web.Scotty.Trans.Strict` and `Web.Scotty.Trans.Lazy`
* Reverted the `MonadReader` instance of `ActionT` so that it inherits the base monad
* renamed `captureParam`, `captureParamMaybe`, and `captureParams` to `pathParam`, `pathParamMaybe`, `pathParams` respectively, keeping the old names as their synonyms
* deprecate `rescue` and `liftAndCatchIO` (#332)
* add `Web.Scotty.Trans.Strict` and `Web.Scotty.Trans.Lazy` (#334)
* Reverted the `MonadReader` instance of `ActionT` so that it inherits the base monad (#342)
* renamed `captureParam`, `captureParamMaybe`, and `captureParams` to `pathParam`, `pathParamMaybe`, `pathParams` respectively, keeping the old names as their synonyms (#344)
* Scotty's API such as `queryParam` now throws `ScottyException` rather than `StatusException`.
Uncaught exceptions are handled by `scottyExceptionHandler`, resembling the existing behaviour
* Deprecate `StatusError`, `raise` and `raiseStatus`
* Deprecate `StatusError`, `raise` and `raiseStatus` (#351)
* Add doctest, refactor some inline examples into doctests (#353)
* document "`defaultHandler` only applies to endpoints defined after it" (#237)

## 0.20.1 [2023.10.03]

Expand Down
11 changes: 11 additions & 0 deletions test/Web/ScottySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ spec = do
withApp (Scotty.get "/" $ throw E.DivideByZero) $ do
it "returns 500 on exceptions" $ do
get "/" `shouldRespondWith` "" {matchStatus = 500}
context "only applies to endpoints defined after it (#237)" $ do
withApp (do
let h = Handler (\(_ :: E.SomeException) -> status status503 >> text "ok")
Scotty.get "/a" (throw E.DivideByZero)
defaultHandler h
Scotty.get "/b" (throw E.DivideByZero)
) $ do
it "doesn't catch an exception before the handler is set" $ do
get "/a" `shouldRespondWith` 500
it "catches an exception after the handler is set" $ do
get "/b" `shouldRespondWith` "ok" {matchStatus = 503}


describe "setMaxRequestBodySize" $ do
Expand Down
Loading