Created
August 3, 2016 08:03
-
-
Save bgamari/231ca6762fa41729f0af76136cd16924 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import GHC.Stack | |
import Control.Monad.Catch | |
main :: IO () | |
main = execute 5 >>= print | |
execute :: (?loc :: CallStack) => Int -> IO Int | |
execute n = addCallStack $ print n >> fail "hello" | |
addCallStack :: (MonadCatch m, ?loc :: CallStack) => m a -> m a | |
addCallStack = handleAll (throwM . SqlErrorStack ?loc) | |
data SqlErrorStack = SqlErrorStack CallStack SomeException | |
deriving (Show) | |
instance Exception SqlErrorStack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment