module Control.Exception.Throwable
( GeneralException (..)
, generalException
, IOException' (..)
, ioException'
, IllegalArgumentException (..)
, illegalArgumentException
, IndexOutOfBoundsException (..)
, indexOutOfBoundsException
) where
import Control.Exception.Safe (Exception)
import Control.Exception.Throwable.TH (declareException)
import Data.Typeable (Typeable)
data GeneralException a = GeneralException
{ exceptionName :: String
, exceptionCause :: String
, exceptionClue :: a
}
instance Show a => Show (GeneralException a) where
show (GeneralException name cause _) = name ++ ": " ++ cause
instance (Typeable a, Show a) => Exception (GeneralException a)
generalException :: String -> String -> GeneralException ()
generalException name cause = GeneralException name cause ()
declareException "IOException'" ["IOException'", "FileNotFoundException"]
declareException "IndexOutOfBoundsException" ["IndexOutOfBoundsException"]
declareException "IllegalArgumentException" ["IllegalArgumentException"]