module Test.Tasty.Runners.Utils where
import Control.Exception
import Control.DeepSeq
import Control.Applicative
import Prelude
import Text.Printf
formatMessage :: String -> IO String
formatMessage msg = go 3 msg
where
go :: Int -> String -> IO String
go 0 _ = return "exceptions keep throwing other exceptions!"
go recLimit msg = do
mbStr <- try $ evaluate $ force msg
case mbStr of
Right str -> return str
Left e' -> printf "message threw an exception: %s" <$> go (recLimit1) (show (e' :: SomeException))