From a59f63e0336ee61f7a90b8778e9147305d3127bb Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 30 Jun 2021 15:53:11 +0200 Subject: [PATCH] Use displayException --- yesod-core/src/Yesod/Core/Internal/Response.hs | 4 ++-- yesod-core/src/Yesod/Core/Internal/Run.hs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/yesod-core/src/Yesod/Core/Internal/Response.hs b/yesod-core/src/Yesod/Core/Internal/Response.hs index abf0cdfa..4f40dbf1 100644 --- a/yesod-core/src/Yesod/Core/Internal/Response.hs +++ b/yesod-core/src/Yesod/Core/Internal/Response.hs @@ -17,7 +17,7 @@ import Yesod.Core.Content import Yesod.Core.Types import qualified Network.HTTP.Types as H import qualified Data.Text as T -import Control.Exception (SomeException, handle) +import Control.Exception (SomeException, handle, displayException) import Data.ByteString.Builder (lazyByteString, toLazyByteString) import qualified Data.ByteString.Lazy as L 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') where 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) getStatus :: ErrorResponse -> H.Status diff --git a/yesod-core/src/Yesod/Core/Internal/Run.hs b/yesod-core/src/Yesod/Core/Internal/Run.hs index 8f0afee9..9cb7044f 100644 --- a/yesod-core/src/Yesod/Core/Internal/Run.hs +++ b/yesod-core/src/Yesod/Core/Internal/Run.hs @@ -47,11 +47,11 @@ toErrorHandler e0 = handleAny errFromShow $ Just (HCError x) -> evaluate $!! x _ -> 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 x = do - text <- evaluate (T.pack $ show x) `catchAny` \_ -> - return (T.pack "Yesod.Core.Internal.Run.errFromShow: show of an exception threw an exception") + text <- evaluate (T.pack $ displayException x) `catchAny` \_ -> + return (T.pack "Yesod.Core.Internal.Run.errFromShow: display of an exception threw an exception") return $ InternalError text -- | Do a basic run of a handler, getting some contents and the final