From 829b107eb989cefe4156b27174e8429a5f57baf5 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 8 Jan 2015 18:18:47 +0200 Subject: [PATCH] Don't let a SQL connection failure be a problem during defaultLayout --- Foundation.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Foundation.hs b/Foundation.hs index 79aeb57..0e7389e 100644 --- a/Foundation.hs +++ b/Foundation.hs @@ -5,6 +5,7 @@ import Data.BlobStore import Data.Slug (safeMakeSlug, HasGenIO (getGenIO), randomSlug, Slug, SnapSlug) import Data.WebsiteContent import qualified Database.Persist +import Database.Persist.Sql (PersistentSqlException (Couldn'tGetSQLConnection)) import Model import qualified Settings import Settings (widgetFile, Extra (..), GoogleAuth (..)) @@ -95,7 +96,9 @@ instance Yesod App where defaultLayout widget = do mmsg <- getMessage - muser <- maybeAuth + muser <- catch maybeAuth $ \e -> case e of + Couldn'tGetSQLConnection -> return Nothing + _ -> throwM e -- We break up the default layout into two components: -- default-layout is the contents of the body tag, and