{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Safe #-}
-- |
-- Module       : Data.Text.Encoding.Base32.Error
-- Copyright    : (c) 2019-2020 Emily Pillmore
-- License      : BSD-style
--
-- Maintainer   : Emily Pillmore <emilypi@cohomolo.gy>
-- Stability    : stable
-- Portability  : non-portable
--
-- This module contains the error types raised (not as exceptions!)
-- in the decoding process.
--
module Data.Text.Encoding.Base32.Error
( Base32Error(..)
) 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 Base32Error e
  = DecodeError Text
    -- ^ The error associated with decoding failure
    -- as a result of the Base32 decoding process
  | ConversionError e
    -- ^ The error associated with the decoding failure
    -- as a result of the conversion process
  deriving
    ( Base32Error e -> Base32Error e -> Bool
(Base32Error e -> Base32Error e -> Bool)
-> (Base32Error e -> Base32Error e -> Bool) -> Eq (Base32Error e)
forall e. Eq e => Base32Error e -> Base32Error e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Base32Error e -> Base32Error e -> Bool
$c/= :: forall e. Eq e => Base32Error e -> Base32Error e -> Bool
== :: Base32Error e -> Base32Error e -> Bool
$c== :: forall e. Eq e => Base32Error e -> Base32Error e -> Bool
Eq, Int -> Base32Error e -> ShowS
[Base32Error e] -> ShowS
Base32Error e -> String
(Int -> Base32Error e -> ShowS)
-> (Base32Error e -> String)
-> ([Base32Error e] -> ShowS)
-> Show (Base32Error e)
forall e. Show e => Int -> Base32Error e -> ShowS
forall e. Show e => [Base32Error e] -> ShowS
forall e. Show e => Base32Error e -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Base32Error e] -> ShowS
$cshowList :: forall e. Show e => [Base32Error e] -> ShowS
show :: Base32Error e -> String
$cshow :: forall e. Show e => Base32Error e -> String
showsPrec :: Int -> Base32Error e -> ShowS
$cshowsPrec :: forall e. Show e => Int -> Base32Error e -> ShowS
Show
    , Generic
      -- ^ @since 0.2.0.0
    )

-- |
--
-- @since 0.2.0.0
--
instance Exception e => Exception (Base32Error e)


-- |
--
-- @since 0.2.0.0
--
instance NFData e => NFData (Base32Error e)