Skip to content

Commit

Permalink
Implement MonadThrow instance for AppM(fix #62)
Browse files Browse the repository at this point in the history
  • Loading branch information
sras committed Dec 21, 2016
1 parent 7dabc30 commit 463b565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions ServantOpaleye2/ServantOpaleye2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ library
,unordered-containers
,template-haskell
,lifted-base
,exceptions
default-language: Haskell2010

executable ServantOpaleye2-exe
Expand Down
5 changes: 5 additions & 0 deletions ServantOpaleye2/src/AppM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Control.Monad.Trans.Except
import Control.Monad.Trans.Reader
import Control.Monad.Trans.Writer
import Database.PostgreSQL.Simple
import Control.Monad.Catch
import Control.Monad.Trans.Class

type AppM = WriterT String (ReaderT (Connection, Maybe Tenant, Maybe User) (ExceptT SomeException IO))

Expand All @@ -25,3 +27,6 @@ instance DbConnection AppM where
getConnection = do
(conn, tenant, _) <- R.ask
return conn

instance MonadThrow AppM where
throwM e = lift $ lift $ ExceptT (return $ Left $ SomeException e)

0 comments on commit 463b565

Please sign in to comment.