encoding/Data/Encoding/Exception.hs
Daniel Wagner 9da33cd371 add Ord and Read instances to the encoding/decoding exceptions
Ignore-this: 5ec11b8739b241f1cc2935f5f8e34bfb

darcs-hash:20121208023123-76d51-b27be713e80337673d35c2b749a52e964810b17b
2012-12-07 18:31:23 -08:00

31 lines
1.0 KiB
Haskell

{-# LANGUAGE DeriveDataTypeable #-}
module Data.Encoding.Exception where
import Control.Exception.Extensible
import Data.Word
import Data.Typeable
import Control.Monad.Identity
-- | This exception type is thrown whenever something went wrong during the
-- encoding-process.
data EncodingException
= HasNoRepresentation Char -- ^ Thrown if a specific character
-- is not representable in an encoding.
deriving (Eq,Ord,Show,Read,Typeable)
instance Exception EncodingException
-- | This exception type is thrown whenever something went wrong during the
-- decoding-process.
data DecodingException
= IllegalCharacter Word8 -- ^ The sequence contained an illegal
-- byte that couldn't be decoded.
| UnexpectedEnd -- ^ more bytes were needed to allow a
-- successfull decoding.
| OutOfRange -- ^ the decoded value was out of the unicode range
| IllegalRepresentation [Word8] -- ^ The character sequence encodes a
-- character, but is illegal.
deriving (Eq,Ord,Show,Read,Typeable)
instance Exception DecodingException