chore(error): revert 54a956dc36 ff since it did not help towards #40
This commit is contained in:
parent
db77850c4f
commit
ce45d26a21
@ -9,9 +9,9 @@ module Foundation.Yesod.ErrorHandler
|
|||||||
import Import.NoFoundation hiding (errorHandler)
|
import Import.NoFoundation hiding (errorHandler)
|
||||||
|
|
||||||
import Foundation.Type
|
import Foundation.Type
|
||||||
-- import Foundation.I18n
|
import Foundation.I18n
|
||||||
import Foundation.Authorization
|
import Foundation.Authorization
|
||||||
-- import Foundation.SiteLayout
|
import Foundation.SiteLayout
|
||||||
import Foundation.Routes
|
import Foundation.Routes
|
||||||
import Foundation.DB
|
import Foundation.DB
|
||||||
|
|
||||||
@ -20,15 +20,15 @@ import qualified Data.Text as Text
|
|||||||
|
|
||||||
import qualified Network.Wai as W
|
import qualified Network.Wai as W
|
||||||
|
|
||||||
-- import System.Exit -- DEBUG: just for testing
|
import System.Exit -- DEBUG: just for testing
|
||||||
-- import System.Posix.Process -- DEBUG: just for testing
|
import System.Posix.Process -- DEBUG: just for testing
|
||||||
|
|
||||||
errorHandler :: ( MonadSecretBox (HandlerFor UniWorX)
|
errorHandler :: ( MonadSecretBox (HandlerFor UniWorX)
|
||||||
-- , MonadSecretBox (WidgetFor UniWorX)
|
, MonadSecretBox (WidgetFor UniWorX)
|
||||||
, MonadSecretBox (ExceptT EncodedSecretBoxException (HandlerFor UniWorX))
|
, MonadSecretBox (ExceptT EncodedSecretBoxException (HandlerFor UniWorX))
|
||||||
, MonadAuth (HandlerFor UniWorX)
|
, MonadAuth (HandlerFor UniWorX)
|
||||||
, BearerAuthSite UniWorX
|
, BearerAuthSite UniWorX
|
||||||
-- , YesodPersistBackend UniWorX ~ SqlBackend
|
, YesodPersistBackend UniWorX ~ SqlBackend
|
||||||
)
|
)
|
||||||
=> ErrorResponse -> HandlerFor UniWorX TypedContent
|
=> ErrorResponse -> HandlerFor UniWorX TypedContent
|
||||||
errorHandler err = do
|
errorHandler err = do
|
||||||
@ -72,39 +72,39 @@ errorHandler err = do
|
|||||||
setSessionJson SessionError sessErr
|
setSessionJson SessionError sessErr
|
||||||
|
|
||||||
selectRep $ do
|
selectRep $ do
|
||||||
-- provideRep $ do
|
provideRep $ do
|
||||||
-- mr <- getMessageRender
|
mr <- getMessageRender
|
||||||
-- let
|
let
|
||||||
-- encrypted :: Text -> WidgetFor UniWorX () -> WidgetFor UniWorX ()
|
encrypted :: Text -> WidgetFor UniWorX () -> WidgetFor UniWorX ()
|
||||||
-- encrypted plaintextJson plaintext = do
|
encrypted plaintextJson plaintext = do
|
||||||
-- let displayEncrypted ciphertext =
|
let displayEncrypted ciphertext =
|
||||||
-- [whamlet|
|
[whamlet|
|
||||||
-- $newline never
|
$newline never
|
||||||
-- <p>_{MsgErrorResponseEncrypted}
|
<p>_{MsgErrorResponseEncrypted}
|
||||||
-- <pre .literal-error>
|
<pre .literal-error>
|
||||||
-- #{ciphertext}
|
#{ciphertext}
|
||||||
-- |]
|
|]
|
||||||
-- if
|
if
|
||||||
-- | isEncrypted && shouldEncrypt -> displayEncrypted plaintextJson
|
| isEncrypted && shouldEncrypt -> displayEncrypted plaintextJson
|
||||||
-- | shouldEncrypt -> displayEncrypted =<< encodedSecretBox SecretBoxPretty plaintextJson
|
| shouldEncrypt -> displayEncrypted =<< encodedSecretBox SecretBoxPretty plaintextJson
|
||||||
-- | otherwise -> plaintext
|
| otherwise -> plaintext
|
||||||
|
|
||||||
-- errPage = case err of
|
errPage = case err of
|
||||||
-- NotFound -> [whamlet|<p>_{MsgErrorResponseNotFound}|]
|
NotFound -> [whamlet|<p>_{MsgErrorResponseNotFound}|]
|
||||||
-- InternalError err'
|
InternalError err'
|
||||||
-- | "Crash Button" `isPrefixOf` err' -> liftIO $ exitImmediately ExitSuccess -- DEBUG: just for Testing
|
| "Crash Button" `isPrefixOf` err' -> liftIO $ exitImmediately ExitSuccess -- DEBUG: just for Testing
|
||||||
-- | otherwise -> encrypted err' [whamlet|<p .literal-error>#{fromMaybe err' decrypted}|]
|
| otherwise -> encrypted err' [whamlet|<p .literal-error>#{fromMaybe err' decrypted}|]
|
||||||
-- InvalidArgs errs -> [whamlet|
|
InvalidArgs errs -> [whamlet|
|
||||||
-- <ul>
|
<ul>
|
||||||
-- $forall err' <- errs
|
$forall err' <- errs
|
||||||
-- <li .literal-error>
|
<li .literal-error>
|
||||||
-- #{err'}
|
#{err'}
|
||||||
-- |]
|
|]
|
||||||
-- NotAuthenticated -> [whamlet|<p>_{MsgErrorResponseNotAuthenticated}|]
|
NotAuthenticated -> [whamlet|<p>_{MsgErrorResponseNotAuthenticated}|]
|
||||||
-- PermissionDenied err' -> [whamlet|<p .errMsg>#{err'}|]
|
PermissionDenied err' -> [whamlet|<p .errMsg>#{err'}|]
|
||||||
-- BadMethod method -> [whamlet|<p>_{MsgErrorResponseBadMethod (decodeUtf8 method)}|]
|
BadMethod method -> [whamlet|<p>_{MsgErrorResponseBadMethod (decodeUtf8 method)}|]
|
||||||
-- siteLayout (toWgt . mr $ ErrorResponseTitle err) $ do
|
siteLayout (toWgt . mr $ ErrorResponseTitle err) $ do
|
||||||
-- errPage
|
errPage
|
||||||
provideRep $ case err of
|
provideRep $ case err of
|
||||||
PermissionDenied err' -> return err'
|
PermissionDenied err' -> return err'
|
||||||
InternalError err'
|
InternalError err'
|
||||||
|
|||||||
Reference in New Issue
Block a user