mirror of
https://github.com/tfausak/witch.git
synced 2024-11-22 14:58:13 +03:00
Improve display of try cast exceptions
This commit is contained in:
parent
634c06ca7d
commit
b4c14ea8af
@ -8,18 +8,21 @@ import qualified Data.Typeable as Typeable
|
||||
|
||||
newtype TryCastException source target
|
||||
= TryCastException source
|
||||
deriving (Eq, Show)
|
||||
deriving Eq
|
||||
|
||||
instance
|
||||
( Show source
|
||||
, Typeable.Typeable source
|
||||
, Typeable.Typeable target
|
||||
) => Exception.Exception (TryCastException source target) where
|
||||
displayException (TryCastException x) = mconcat
|
||||
[ "TryCastException: failed to cast value "
|
||||
, show x
|
||||
, " from type "
|
||||
, show $ Typeable.typeOf x
|
||||
, " into type "
|
||||
, show $ Typeable.typeRep (Proxy.Proxy :: Proxy.Proxy target)
|
||||
]
|
||||
) => Show (TryCastException source target) where
|
||||
showsPrec d (TryCastException x) = showParen (d > 10)
|
||||
$ showString "TryCastException {- "
|
||||
. shows (Typeable.typeRep (Proxy.Proxy :: Proxy.Proxy (source -> target)))
|
||||
. showString " -} "
|
||||
. showsPrec 11 x
|
||||
|
||||
instance
|
||||
( Show source
|
||||
, Typeable.Typeable source
|
||||
, Typeable.Typeable target
|
||||
) => Exception.Exception (TryCastException source target)
|
||||
|
Loading…
Reference in New Issue
Block a user