I have Exception type UnknownException, which I'd like to include the CallStack when it's thrown.
module Main where
import Control.Exception (Exception, throw)
newtype UnknownException = UnknownException
{ caller :: String
} deriving (Show)
instance Exception UnknownException
main :: IO ()
main = willThrow
willThrow :: IO ()
willThrow = throw $ UnknownException "willThrow"
I'd like the above example to print logs like this
example-exe: UnknownException {caller = "willThrow"}
CallStack (from HasCallStack):
willThrow, called at app/Main.hs:16:13 in main:Main
main, called at app/Main.hs:13:8 in main:Main
but actually printed:
example-exe: UnknownException {caller = "willThrow"}
Also, is it a good practice to include CallStack in exceptions in Haskell?