File: Exception.hs

package info (click to toggle)
haskell-encoding 0.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,392 kB
  • sloc: haskell: 4,372; ansic: 11; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 1,075 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# 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