module Web.JWT.ASAP.Error (
  HasAsapError (..)
, AsapError (..)
) where

import           Control.Lens (Prism', prism')

class HasAsapError e where
  asapMissingEnv :: Prism' e String
  asapInvalidSecret :: Prism' e ()

instance HasAsapError AsapError where
  asapMissingEnv =
    prism' AsapMissingEnv f
    where
      f (AsapMissingEnv a) =
        Just a
      f _ =
        Nothing
  asapInvalidSecret =
    prism' (const AsapInvalidSecret) f
    where
      f AsapInvalidSecret =
        Just ()
      f _ =
        Nothing

data AsapError
  = AsapMissingEnv String
  | AsapInvalidSecret
  deriving (Eq, Ord, Show)
