From b67d225f56a98f4e000bf415ecc1713b84a36b39 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 10 Apr 2014 20:30:14 +0300 Subject: [PATCH] Use mplus (thanks @meteficha) --- yesod-core/Yesod/Core/Internal/Run.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/yesod-core/Yesod/Core/Internal/Run.hs b/yesod-core/Yesod/Core/Internal/Run.hs index d20fd7f4..a5c192b4 100644 --- a/yesod-core/Yesod/Core/Internal/Run.hs +++ b/yesod-core/Yesod/Core/Internal/Run.hs @@ -13,6 +13,7 @@ import Control.Applicative ((<$>)) import Control.Exception (fromException, bracketOnError, evaluate) import qualified Control.Exception as E import Control.Exception.Lifted (catch) +import Control.Monad (mplus) import Control.Monad.IO.Class (MonadIO) import Control.Monad.IO.Class (liftIO) import Control.Monad.Logger (LogLevel (LevelError), LogSource, @@ -91,12 +92,9 @@ runHandler rhe@RunHandlerEnv {..} handler yreq = withInternalState $ \resState - ([], Just $! HCError $! InternalError $! T.pack $! show (e :: E.SomeException)) let contents = - case mcontents1 of + case mcontents1 `mplus` mcontents2 of Just x -> x - Nothing -> - case mcontents2 of - Just x -> x - Nothing -> either id (HCContent defaultStatus . toTypedContent) contents' + Nothing -> either id (HCContent defaultStatus . toTypedContent) contents' let handleError e = flip runInternalState resState $ do yar <- rheOnError e yreq { reqSession = finalSession