Add a warning about DB actions getting rolled back

This commit is contained in:
Alexey Zabelin 2019-11-13 20:55:47 -08:00
parent e333735176
commit 19f4b26e1f
No known key found for this signature in database
GPG Key ID: 3A169985478324E9

View File

@ -91,7 +91,8 @@ module Yesod.Core.Handler
, permissionDeniedI
, invalidArgs
, invalidArgsI
-- ** Short-circuit responses.
-- ** Short-circuit responses
-- $rollbackWarning
, sendFile
, sendFilePart
, sendResponse
@ -607,6 +608,20 @@ setMessageI = addMessageI ""
getMessage :: MonadHandler m => m (Maybe Html)
getMessage = fmap (fmap snd . listToMaybe) getMessages
-- $rollbackWarning
--
-- Note that since short-circuiting is implemented by using exceptions,
-- using e.g. 'sendStatusJSON' inside a runDB block
-- will result in the database actions getting rolled back:
--
-- @
-- runDB $ do
-- userId <- insert $ User "username" "email@example.com"
-- postId <- insert $ BlogPost "title" "hi there!"
-- /The previous two inserts will be rolled back./
-- sendStatusJSON Status.status200 ()
-- @
-- | Bypass remaining handler code and output the given file.
--
-- For some backends, this is more efficient than reading in the file to