module Text.Show.Text.Control.Exception (
showbSomeExceptionPrec
, showbIOException
, showbArithException
, showbArrayException
, showbAssertionFailed
#if MIN_VERSION_base(4,7,0)
, showbSomeAsyncException
#endif
, showbAsyncException
, showbNonTermination
, showbNestedAtomically
, showbBlockedIndefinitelyOnMVar
, showbBlockedIndefinitelyOnSTM
#if MIN_VERSION_base(4,8,0)
, showbAllocationLimitExceeded
#endif
, showbDeadlock
, showbNoMethodError
, showbPatternMatchFail
, showbRecConError
, showbRecSelError
, showbRecUpdError
, showbErrorCall
, showbMaskingState
) where
import Control.Exception.Base
#if !(MIN_VERSION_base(4,8,0))
import Data.Monoid (mempty)
#endif
import Data.Text.Lazy.Builder (Builder, fromString)
import Prelude hiding (Show)
import Text.Show.Text.Classes (Show(showb, showbPrec), FromStringShow(..))
import Text.Show.Text.TH.Internal (deriveShowPragmas, defaultInlineShowb)
import Text.Show.Text.Utils ((<>))
#include "inline.h"
showbSomeExceptionPrec :: Int -> SomeException -> Builder
showbSomeExceptionPrec p (SomeException e) = showbPrec p $ FromStringShow e
showbIOException :: IOException -> Builder
showbIOException = showb . FromStringShow
showbArithException :: ArithException -> Builder
showbArithException Overflow = "arithmetic overflow"
showbArithException Underflow = "arithmetic underflow"
showbArithException LossOfPrecision = "loss of precision"
showbArithException DivideByZero = "divide by zero"
showbArithException Denormal = "denormal"
#if MIN_VERSION_base(4,6,0)
showbArithException RatioZeroDenominator = "Ratio has zero denominator"
#endif
showbArrayException :: ArrayException -> Builder
showbArrayException (IndexOutOfBounds s)
= "array index out of range"
<> (if not $ null s then ": " <> fromString s
else mempty)
showbArrayException (UndefinedElement s)
= "undefined array element"
<> (if not $ null s then ": " <> fromString s
else mempty)
showbAssertionFailed :: AssertionFailed -> Builder
showbAssertionFailed (AssertionFailed err) = fromString err
#if MIN_VERSION_base(4,7,0)
showbSomeAsyncException :: SomeAsyncException -> Builder
showbSomeAsyncException (SomeAsyncException e) = showb $ FromStringShow e
#endif
showbAsyncException :: AsyncException -> Builder
showbAsyncException StackOverflow = "stack overflow"
showbAsyncException HeapOverflow = "heap overflow"
showbAsyncException ThreadKilled = "thread killed"
showbAsyncException UserInterrupt = "user interrupt"
showbNonTermination :: NonTermination -> Builder
showbNonTermination NonTermination = "<<loop>>"
showbNestedAtomically :: NestedAtomically -> Builder
showbNestedAtomically NestedAtomically = "Control.Concurrent.STM.atomically was nested"
showbBlockedIndefinitelyOnMVar :: BlockedIndefinitelyOnMVar -> Builder
showbBlockedIndefinitelyOnMVar BlockedIndefinitelyOnMVar = "thread blocked indefinitely in an MVar operation"
showbBlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM -> Builder
showbBlockedIndefinitelyOnSTM BlockedIndefinitelyOnSTM = "thread blocked indefinitely in an STM transaction"
#if MIN_VERSION_base(4,8,0)
showbAllocationLimitExceeded :: AllocationLimitExceeded -> Builder
showbAllocationLimitExceeded AllocationLimitExceeded = "allocation limit exceeded"
#endif
showbDeadlock :: Deadlock -> Builder
showbDeadlock Deadlock = "<<deadlock>>"
showbNoMethodError :: NoMethodError -> Builder
showbNoMethodError (NoMethodError err) = fromString err
showbPatternMatchFail :: PatternMatchFail -> Builder
showbPatternMatchFail (PatternMatchFail err) = fromString err
showbRecConError :: RecConError -> Builder
showbRecConError (RecConError err) = fromString err
showbRecSelError :: RecSelError -> Builder
showbRecSelError (RecSelError err) = fromString err
showbRecUpdError :: RecUpdError -> Builder
showbRecUpdError (RecUpdError err) = fromString err
showbErrorCall :: ErrorCall -> Builder
showbErrorCall (ErrorCall err) = fromString err
showbMaskingState :: MaskingState -> Builder
showbMaskingState = showb
instance Show SomeException where
showbPrec = showbSomeExceptionPrec
INLINE_INST_FUN(showbPrec)
instance Show IOException where
showb = showbIOException
INLINE_INST_FUN(showb)
instance Show ArithException where
showb = showbArithException
INLINE_INST_FUN(showb)
instance Show ArrayException where
showb = showbArrayException
INLINE_INST_FUN(showb)
instance Show AssertionFailed where
showb = showbAssertionFailed
INLINE_INST_FUN(showb)
#if MIN_VERSION_base(4,7,0)
instance Show SomeAsyncException where
showb = showbSomeAsyncException
#endif
instance Show AsyncException where
showb = showbAsyncException
INLINE_INST_FUN(showb)
instance Show NonTermination where
showb = showbNonTermination
INLINE_INST_FUN(showb)
instance Show NestedAtomically where
showb = showbNestedAtomically
INLINE_INST_FUN(showb)
instance Show BlockedIndefinitelyOnMVar where
showb = showbBlockedIndefinitelyOnMVar
INLINE_INST_FUN(showb)
instance Show BlockedIndefinitelyOnSTM where
showb = showbBlockedIndefinitelyOnSTM
INLINE_INST_FUN(showb)
#if MIN_VERSION_base(4,8,0)
instance Show AllocationLimitExceeded where
showb = showbAllocationLimitExceeded
#endif
instance Show Deadlock where
showb = showbDeadlock
INLINE_INST_FUN(showb)
instance Show NoMethodError where
showb = showbNoMethodError
INLINE_INST_FUN(showb)
instance Show PatternMatchFail where
showb = showbPatternMatchFail
INLINE_INST_FUN(showb)
instance Show RecConError where
showb = showbRecConError
INLINE_INST_FUN(showb)
instance Show RecSelError where
showb = showbRecSelError
INLINE_INST_FUN(showb)
instance Show RecUpdError where
showb = showbRecUpdError
INLINE_INST_FUN(showb)
instance Show ErrorCall where
showb = showbErrorCall
INLINE_INST_FUN(showb)
$(deriveShowPragmas defaultInlineShowb ''MaskingState)