diff --git a/ServantOpaleye2/ServantOpaleye2.cabal b/ServantOpaleye2/ServantOpaleye2.cabal index 73996a3..c339f45 100644 --- a/ServantOpaleye2/ServantOpaleye2.cabal +++ b/ServantOpaleye2/ServantOpaleye2.cabal @@ -61,6 +61,7 @@ library ,unordered-containers ,template-haskell ,lifted-base + ,exceptions default-language: Haskell2010 executable ServantOpaleye2-exe diff --git a/ServantOpaleye2/src/AppM.hs b/ServantOpaleye2/src/AppM.hs index 7dc9cff..b638392 100644 --- a/ServantOpaleye2/src/AppM.hs +++ b/ServantOpaleye2/src/AppM.hs @@ -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)) @@ -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)