File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
src/Servant/Server/Internal Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
Package versions follow the [ Package Versioning Policy] ( https://pvp.haskell.org/ ) : in A.B.C, bumps to either A or B represent major versions.
5
5
6
+ Unreleased
7
+ ----------
8
+
9
+ - Add ` MonadFail ` instance for ` Handler ` wrt [ #1545 ] ( https://github.com/haskell-servant/servant/issues/1545 )
10
+
6
11
0.19
7
12
----
8
13
Original file line number Diff line number Diff line change @@ -13,17 +13,19 @@ import Control.Monad.Base
13
13
import Control.Monad.Catch
14
14
(MonadCatch , MonadMask , MonadThrow )
15
15
import Control.Monad.Error.Class
16
- (MonadError )
16
+ (MonadError , throwError )
17
17
import Control.Monad.IO.Class
18
18
(MonadIO )
19
19
import Control.Monad.Trans.Control
20
20
(MonadBaseControl (.. ))
21
21
import Control.Monad.Trans.Except
22
22
(ExceptT , runExceptT )
23
+ import Data.String
24
+ (fromString )
23
25
import GHC.Generics
24
26
(Generic )
25
27
import Servant.Server.Internal.ServerError
26
- (ServerError )
28
+ (ServerError , errBody , err500 )
27
29
28
30
newtype Handler a = Handler { runHandler' :: ExceptT ServerError IO a }
29
31
deriving
@@ -32,6 +34,9 @@ newtype Handler a = Handler { runHandler' :: ExceptT ServerError IO a }
32
34
, MonadThrow , MonadCatch , MonadMask
33
35
)
34
36
37
+ instance MonadFail Handler where
38
+ fail str = throwError err500 { errBody = fromString str }
39
+
35
40
instance MonadBase IO Handler where
36
41
liftBase = Handler . liftBase
37
42
You can’t perform that action at this time.
0 commit comments