Now it's possible to change the character encoding while de-/encoding. Also, it's possible to use any data structure as a source or target of the de-/encoding process. darcs-hash:20090221203100-a4fee-6da31f2e37c30a3f5cd5f10af71984209488bb0b
31 lines
1.0 KiB
Haskell
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,Show,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,Show,Typeable)
|
|
|
|
instance Exception DecodingException
|