|
8 | 8 | {-# LANGUAGE ScopedTypeVariables #-} |
9 | 9 | module Yesod.Core.Internal.Run |
10 | 10 | ( toErrorHandler |
11 | | - , errFromShow |
| 11 | + , errFromDisplayException |
12 | 12 | , basicRunHandler |
13 | 13 | , handleError |
14 | 14 | , handleContents |
@@ -59,17 +59,10 @@ import Data.Proxy(Proxy(..)) |
59 | 59 |
|
60 | 60 | -- | Convert a synchronous exception into an ErrorResponse |
61 | 61 | toErrorHandler :: SomeException -> IO ErrorResponse |
62 | | -toErrorHandler e0 = handleAny errFromShow $ |
| 62 | +toErrorHandler e0 = handleAny errFromDisplayException $ |
63 | 63 | case fromException e0 of |
64 | 64 | Just (HCError x) -> evaluate $!! x |
65 | | - _ -> errFromShow e0 |
66 | | - |
67 | | --- | Generate an @ErrorResponse@ based on the shown version of the exception |
68 | | -errFromShow :: SomeException -> IO ErrorResponse |
69 | | -errFromShow x = do |
70 | | - text <- evaluate (T.pack $ show x) `catchAny` \_ -> |
71 | | - return (T.pack "Yesod.Core.Internal.Run.errFromShow: show of an exception threw an exception") |
72 | | - return $ InternalError text |
| 65 | + _ -> InternalError e0 |
73 | 66 |
|
74 | 67 | -- | Do a basic run of a handler, getting some contents and the final |
75 | 68 | -- @GHState@. The @GHState@ unfortunately may contain some impure |
@@ -128,7 +121,7 @@ handleError :: RunHandlerEnv sub site |
128 | 121 | -> IO YesodResponse |
129 | 122 | handleError rhe yreq resState finalSession headers e0 = do |
130 | 123 | -- Find any evil hidden impure exceptions |
131 | | - e <- (evaluate $!! e0) `catchAny` errFromShow |
| 124 | + e <- (evaluate $!! e0) `catchAny` errFromDisplayException |
132 | 125 |
|
133 | 126 | -- Generate a response, leveraging the updated session and |
134 | 127 | -- response headers |
@@ -263,7 +256,7 @@ runFakeHandler :: forall site m a . (Yesod site, MonadIO m) => |
263 | 256 | -> HandlerFor site a |
264 | 257 | -> m (Either ErrorResponse a) |
265 | 258 | runFakeHandler fakeSessionMap logger site handler = liftIO $ do |
266 | | - ret <- I.newIORef (Left $ InternalError "runFakeHandler: no result") |
| 259 | + ret <- I.newIORef (Left $ InternalError $ toException (EUnsafe.ErrorCall "runFakeHandler: no result")) |
267 | 260 | maxExpires <- getCurrentMaxExpiresRFC1123 |
268 | 261 | let handler' = liftIO . I.writeIORef ret . Right =<< handler |
269 | 262 | let yapp = runHandler |
|
0 commit comments