Use displayException
This commit is contained in:
parent
cb75192e0c
commit
a59f63e033
@ -17,7 +17,7 @@ import Yesod.Core.Content
|
|||||||
import Yesod.Core.Types
|
import Yesod.Core.Types
|
||||||
import qualified Network.HTTP.Types as H
|
import qualified Network.HTTP.Types as H
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Control.Exception (SomeException, handle)
|
import Control.Exception (SomeException, handle, displayException)
|
||||||
import Data.ByteString.Builder (lazyByteString, toLazyByteString)
|
import Data.ByteString.Builder (lazyByteString, toLazyByteString)
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
@ -101,7 +101,7 @@ evaluateContent (ContentBuilder b mlen) = handle f $ do
|
|||||||
len `seq` return (Right $ ContentBuilder (lazyByteString lbs) mlen')
|
len `seq` return (Right $ ContentBuilder (lazyByteString lbs) mlen')
|
||||||
where
|
where
|
||||||
f :: SomeException -> IO (Either ErrorResponse Content)
|
f :: SomeException -> IO (Either ErrorResponse Content)
|
||||||
f = return . Left . InternalError . T.pack . show
|
f = return . Left . InternalError . T.pack . displayException
|
||||||
evaluateContent c = return (Right c)
|
evaluateContent c = return (Right c)
|
||||||
|
|
||||||
getStatus :: ErrorResponse -> H.Status
|
getStatus :: ErrorResponse -> H.Status
|
||||||
|
|||||||
@ -47,11 +47,11 @@ toErrorHandler e0 = handleAny errFromShow $
|
|||||||
Just (HCError x) -> evaluate $!! x
|
Just (HCError x) -> evaluate $!! x
|
||||||
_ -> errFromShow e0
|
_ -> errFromShow e0
|
||||||
|
|
||||||
-- | Generate an @ErrorResponse@ based on the shown version of the exception
|
-- | Generate an @ErrorResponse@ based on the displayed version of the exception
|
||||||
errFromShow :: SomeException -> IO ErrorResponse
|
errFromShow :: SomeException -> IO ErrorResponse
|
||||||
errFromShow x = do
|
errFromShow x = do
|
||||||
text <- evaluate (T.pack $ show x) `catchAny` \_ ->
|
text <- evaluate (T.pack $ displayException x) `catchAny` \_ ->
|
||||||
return (T.pack "Yesod.Core.Internal.Run.errFromShow: show of an exception threw an exception")
|
return (T.pack "Yesod.Core.Internal.Run.errFromShow: display of an exception threw an exception")
|
||||||
return $ InternalError text
|
return $ InternalError text
|
||||||
|
|
||||||
-- | Do a basic run of a handler, getting some contents and the final
|
-- | Do a basic run of a handler, getting some contents and the final
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user