yesod-auth-oauth2/src/Yesod/Auth/OAuth2/Exception.hs
patrick brisbin 1411bb5858 Implement different exceptions for different cases
I had hoped to get away from this entirely, to an Either-based
interface, but that seems to be stalling as an initiative. So in the
meantime, let's at least make our exceptions more meaningful.
2018-09-19 07:55:38 -04:00

30 lines
724 B
Haskell

{-# LANGUAGE DeriveDataTypeable #-}
module Yesod.Auth.OAuth2.Exception
( YesodOAuth2Exception(..)
) where
import Control.Exception.Safe
import Data.ByteString.Lazy (ByteString)
import Data.Text (Text)
data YesodOAuth2Exception
= OAuth2Error Text ByteString
-- ^ HTTP error during OAuth2 handshake
--
-- Plugin name and JSON-encoded @OAuth2Error@ from @hoauth2@.
--
| JSONDecodingError Text String
-- ^ User profile was not as expected
--
-- Plugin name and Aeson parse error message.
--
| GenericError Text String
-- ^ Other error conditions
--
-- Plugin name and error message.
--
deriving (Show, Typeable)
instance Exception YesodOAuth2Exception