Permalink
Browse files

Print exceptions in runDB

  • Loading branch information...
1 parent 4bf2c03 commit f31de7852fa1e3f466e4fe9a05fbd18208646fc0 @maoe committed Jun 9, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 src/TKYProf/Controller/Internal.hs
@@ -2,8 +2,10 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE ScopedTypeVariables #-}
module TKYProf.Controller.Internal where
import Control.Applicative ((<$>), (<*>))
+import Control.Monad.Trans (MonadIO(..))
import Data.Char (toLower)
import Data.List (stripPrefix)
import Data.Maybe (fromMaybe)
@@ -12,6 +14,7 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Data.Text.Encoding.Error as TEE
+import Control.Exception.Lifted (SomeException, try, throwIO)
import Data.Aeson ((.=))
import qualified Data.Aeson as A
import qualified Data.Attoparsec.Text as AT
@@ -100,7 +103,12 @@ instance YesodPersist TKYProf where
type YesodPersistBackend TKYProf = SqlPersist
runDB act = do
tkyprof <- getYesod
- runSqlPool act $ tkyConnPool tkyprof
+ r <- try $ runSqlPool act $ tkyConnPool tkyprof
+ case r of
+ Left (e :: SomeException) -> do
+ liftIO $ print e
+ throwIO e
+ Right x -> return x
pagenator
:: Int

0 comments on commit f31de78

Please sign in to comment.