{-# LANGUAGE DeriveGeneric #-}
-- |
-- Module       : Data.Text.Encoding.Base16.Error
-- Copyright    : (c) 2019-2023 Emily Pillmore
-- License      : BSD-style
--
-- Maintainer   : Emily Pillmore <emilypi@cohomolo.gy>
-- Stability    : Experimental
-- Portability  : portable
--
-- This module contains the error types raised
-- in the decoding process.
--
module Data.Text.Encoding.Base16.Error
( Base16Error(..)
) where


import Control.DeepSeq (NFData(..))
import Control.Exception (Exception(..))

import Data.Text (Text)

import GHC.Generics


-- | This data type represents the type of decoding errors of
-- various kinds as they pertain to decoding 'Text' values.
-- Namely, to distinguish between decoding errors from opaque
-- unicode exceptions caught in the unicode decoding process.
--
data Base16Error e
  = DecodeError Text
    -- ^ The error associated with decoding failure
    -- as a result of the Base16 decoding process
  | ConversionError e
    -- ^ The error associated with the decoding failure
    -- as a result of the conversion process
  deriving
    ( Base16Error e -> Base16Error e -> Bool
(Base16Error e -> Base16Error e -> Bool)
-> (Base16Error e -> Base16Error e -> Bool) -> Eq (Base16Error e)
forall e. Eq e => Base16Error e -> Base16Error e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall e. Eq e => Base16Error e -> Base16Error e -> Bool
== :: Base16Error e -> Base16Error e -> Bool
$c/= :: forall e. Eq e => Base16Error e -> Base16Error e -> Bool
/= :: Base16Error e -> Base16Error e -> Bool
Eq, Int -> Base16Error e -> ShowS
[Base16Error e] -> ShowS
Base16Error e -> String
(Int -> Base16Error e -> ShowS)
-> (Base16Error e -> String)
-> ([Base16Error e] -> ShowS)
-> Show (Base16Error e)
forall e. Show e => Int -> Base16Error e -> ShowS
forall e. Show e => [Base16Error e] -> ShowS
forall e. Show e => Base16Error e -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall e. Show e => Int -> Base16Error e -> ShowS
showsPrec :: Int -> Base16Error e -> ShowS
$cshow :: forall e. Show e => Base16Error e -> String
show :: Base16Error e -> String
$cshowList :: forall e. Show e => [Base16Error e] -> ShowS
showList :: [Base16Error e] -> ShowS
Show
    , (forall x. Base16Error e -> Rep (Base16Error e) x)
-> (forall x. Rep (Base16Error e) x -> Base16Error e)
-> Generic (Base16Error e)
forall x. Rep (Base16Error e) x -> Base16Error e
forall x. Base16Error e -> Rep (Base16Error e) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall e x. Rep (Base16Error e) x -> Base16Error e
forall e x. Base16Error e -> Rep (Base16Error e) x
$cfrom :: forall e x. Base16Error e -> Rep (Base16Error e) x
from :: forall x. Base16Error e -> Rep (Base16Error e) x
$cto :: forall e x. Rep (Base16Error e) x -> Base16Error e
to :: forall x. Rep (Base16Error e) x -> Base16Error e
Generic
      -- ^ @since 0.3.0.0
    )

-- |
--
-- @since 0.3.0.0
--
instance Exception e => Exception (Base16Error e)


-- |
--
-- @since 0.3.0.0
--
instance NFData e => NFData (Base16Error e)