module Control.Exception.Throwable
( IOException' (..)
, ioException'
, IllegalArgumentException (..)
, illegalArgumentException
, GeneralException (..)
, generalException
, IndexOutOfBoundsException (..)
, indexOutOfBoundsException
) where
import Control.Exception.Safe (Exception)
import Data.Typeable (Typeable)
data IOException' a = IOException' { ioExceptionCause :: String, ioExceptionClue :: a }
| FileNotFoundException { fileNotFoundCause :: String, fileNotFoundClue :: a }
instance Show a => Show (IOException' a) where
show (IOException' cause _) = "IOException': " ++ show cause
show (FileNotFoundException cause _) = "FileNotFoundException: " ++ show cause
instance (Typeable a, Show a) => Exception (IOException' a)
ioException' :: String -> IOException' ()
ioException' = flip IOException' ()
data IllegalArgumentException a = IllegalArgumentException { illegalArgumentCause :: String, illegalArgumentClue :: a }
instance Show a => Show (IllegalArgumentException a) where
show (IllegalArgumentException cause _) = "IllegalArgumentException: " ++ show cause
instance (Typeable a, Show a) => Exception (IllegalArgumentException a)
illegalArgumentException :: String -> IllegalArgumentException ()
illegalArgumentException = flip IllegalArgumentException ()
data IndexOutOfBoundsException a = IndexOutOfBoundsException { indexOutOfBoundsCause :: String, indexOutOfBoundsArgumentClue :: a }
instance Show a => Show (IndexOutOfBoundsException a) where
show (IndexOutOfBoundsException cause _) = "IndexOutOfBoundsException: " ++ show cause
instance (Typeable a, Show a) => Exception (IndexOutOfBoundsException a)
indexOutOfBoundsException :: String -> IndexOutOfBoundsException ()
indexOutOfBoundsException = flip IndexOutOfBoundsException ()
data GeneralException a = GeneralException
{ exceptionName :: String
, exceptionCause :: String
, exceptionClue :: a
}
instance Show a => Show (GeneralException a) where
show (GeneralException name cause _) = name ++ "Exception: " ++ cause
instance (Typeable a, Show a) => Exception (GeneralException a)
generalException :: String -> String -> GeneralException ()
generalException name cause = GeneralException name cause ()