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