Skip to content

Instantly share code, notes, and snippets.

@bgamari
Created August 3, 2016 08:03
Show Gist options
  • Save bgamari/231ca6762fa41729f0af76136cd16924 to your computer and use it in GitHub Desktop.
Save bgamari/231ca6762fa41729f0af76136cd16924 to your computer and use it in GitHub Desktop.
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