Exception instance for ErrorHandler
This commit is contained in:
parent
f96b71e6f1
commit
753477518f
@ -348,9 +348,10 @@ runHandler :: HasReps c
|
|||||||
-> YesodApp
|
-> YesodApp
|
||||||
runHandler handler mrender sroute tomr ma sa =
|
runHandler handler mrender sroute tomr ma sa =
|
||||||
YesodApp $ \eh rr cts initSession -> do
|
YesodApp $ \eh rr cts initSession -> do
|
||||||
let toErrorHandler =
|
let toErrorHandler e =
|
||||||
InternalError
|
case fromException e of
|
||||||
. (show :: Control.Exception.SomeException -> String)
|
Just x -> x
|
||||||
|
Nothing -> InternalError $ show e
|
||||||
let hd = HandlerData
|
let hd = HandlerData
|
||||||
{ handlerRequest = rr
|
{ handlerRequest = rr
|
||||||
, handlerSub = sa
|
, handlerSub = sa
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
-- | Normal users should never need access to these.
|
-- | Normal users should never need access to these.
|
||||||
module Yesod.Internal
|
module Yesod.Internal
|
||||||
( -- * Error responses
|
( -- * Error responses
|
||||||
@ -46,6 +47,8 @@ import qualified Data.Text.Lazy as LT
|
|||||||
import qualified Data.Text.Lazy.Encoding as LT
|
import qualified Data.Text.Lazy.Encoding as LT
|
||||||
|
|
||||||
import qualified Network.Wai as W
|
import qualified Network.Wai as W
|
||||||
|
import Data.Typeable (Typeable)
|
||||||
|
import Control.Exception (Exception)
|
||||||
|
|
||||||
#if GHC7
|
#if GHC7
|
||||||
#define HAMLET hamlet
|
#define HAMLET hamlet
|
||||||
@ -61,7 +64,8 @@ data ErrorResponse =
|
|||||||
| InvalidArgs [String]
|
| InvalidArgs [String]
|
||||||
| PermissionDenied String
|
| PermissionDenied String
|
||||||
| BadMethod String
|
| BadMethod String
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq, Typeable)
|
||||||
|
instance Exception ErrorResponse
|
||||||
|
|
||||||
----- header stuff
|
----- header stuff
|
||||||
-- | Headers to be added to a 'Result'.
|
-- | Headers to be added to a 'Result'.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user