Skip to content

Commit

Permalink
add test for #237 (#357)
Browse files Browse the repository at this point in the history
* add test for #237
  • Loading branch information
ocramz authored Dec 16, 2023
1 parent e6a9735 commit 0d0c1d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
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

0 comments on commit 0d0c1d2

Please sign in to comment.