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