From dc033e1331a3dd727be0b32977b3829c9c65bb37 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 18 Sep 2018 10:39:07 -0400 Subject: [PATCH] Move Exception to its own module This will avoid cycles later. --- src/Yesod/Auth/OAuth2/Exception.hs | 19 +++++++++++++++++++ src/Yesod/Auth/OAuth2/Prelude.hs | 21 +++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 src/Yesod/Auth/OAuth2/Exception.hs diff --git a/src/Yesod/Auth/OAuth2/Exception.hs b/src/Yesod/Auth/OAuth2/Exception.hs new file mode 100644 index 0000000..a2dc047 --- /dev/null +++ b/src/Yesod/Auth/OAuth2/Exception.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveDataTypeable #-} + +module Yesod.Auth.OAuth2.Exception + ( YesodOAuth2Exception(..) + ) where + +import Control.Exception.Safe +import qualified Data.ByteString.Lazy as BL +import Data.Text (Text) + +-- | Provider name and error +-- +-- The error is a lazy bytestring because it's most often encoded JSON. +-- +-- Deprecated. Eventually, we'll return @Either@s all the way up. +-- +data YesodOAuth2Exception = InvalidProfileResponse Text BL.ByteString + deriving (Show, Typeable) +instance Exception YesodOAuth2Exception diff --git a/src/Yesod/Auth/OAuth2/Prelude.hs b/src/Yesod/Auth/OAuth2/Prelude.hs index 65b3bdc..9d0ee56 100644 --- a/src/Yesod/Auth/OAuth2/Prelude.hs +++ b/src/Yesod/Auth/OAuth2/Prelude.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE DeriveDataTypeable #-} -{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TupleSections #-} -- | @@ -8,10 +6,9 @@ -- implementations. May also be useful for writing local providers. -- module Yesod.Auth.OAuth2.Prelude - ( YesodOAuth2Exception(..) - - -- * Provider helpers - , authGetProfile + ( + -- * Provider helpers + authGetProfile , scopeParam , setExtra @@ -55,6 +52,7 @@ module Yesod.Auth.OAuth2.Prelude , module URI.ByteString.Extension -- * Temporary, until I finish re-structuring modules + , YesodOAuth2Exception(..) , authOAuth2 , authOAuth2Widget ) where @@ -74,16 +72,7 @@ import URI.ByteString import URI.ByteString.Extension import Yesod.Auth import Yesod.Auth.OAuth2 - --- | Provider name and error --- --- The error is a lazy bytestring because it's most often encoded JSON. --- --- Deprecated. Eventually, we'll return @Either@s all the way up. --- -data YesodOAuth2Exception = InvalidProfileResponse Text BL.ByteString - deriving (Show, Typeable) -instance Exception YesodOAuth2Exception +import Yesod.Auth.OAuth2.Exception -- | Retrieve a user's profile as JSON --