Skip to content

Commit

Permalink
Print exceptions in runDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitsutoshi Aoe committed Jun 9, 2012
1 parent 4bf2c03 commit f31de78
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/TKYProf/Controller/Internal.hs
Expand Up @@ -2,8 +2,10 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables #-}
module TKYProf.Controller.Internal where module TKYProf.Controller.Internal where
import Control.Applicative ((<$>), (<*>)) import Control.Applicative ((<$>), (<*>))
import Control.Monad.Trans (MonadIO(..))
import Data.Char (toLower) import Data.Char (toLower)
import Data.List (stripPrefix) import Data.List (stripPrefix)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
Expand All @@ -12,6 +14,7 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as TE import qualified Data.Text.Encoding as TE
import qualified Data.Text.Encoding.Error as TEE import qualified Data.Text.Encoding.Error as TEE


import Control.Exception.Lifted (SomeException, try, throwIO)
import Data.Aeson ((.=)) import Data.Aeson ((.=))
import qualified Data.Aeson as A import qualified Data.Aeson as A
import qualified Data.Attoparsec.Text as AT import qualified Data.Attoparsec.Text as AT
Expand Down Expand Up @@ -100,7 +103,12 @@ instance YesodPersist TKYProf where
type YesodPersistBackend TKYProf = SqlPersist type YesodPersistBackend TKYProf = SqlPersist
runDB act = do runDB act = do
tkyprof <- getYesod 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 pagenator
:: Int :: Int
Expand Down

0 comments on commit f31de78

Please sign in to comment.