From 05fde1f464c3632175fb726b358b48ce578e7a96 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 20 Dec 2010 19:00:30 +0200 Subject: [PATCH] getBy404 --- Yesod/Yesod.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Yesod/Yesod.hs b/Yesod/Yesod.hs index 74288fa3..1523f7d4 100644 --- a/Yesod/Yesod.hs +++ b/Yesod/Yesod.hs @@ -15,6 +15,7 @@ module Yesod.Yesod , YesodPersist (..) , module Database.Persist , get404 + , getBy404 -- ** Breadcrumbs , YesodBreadcrumbs (..) , breadcrumbs @@ -392,6 +393,15 @@ get404 key = do Nothing -> lift notFound Just res -> return res +getBy404 :: (PersistBackend (t m), PersistEntity val, Monad (t m), + Failure ErrorResponse m, MonadTrans t) + => Unique val -> t m (Key val, val) +getBy404 ukey = do + mres <- getBy ukey + case mres of + Nothing -> lift notFound + Just res -> return res + -- | Return the same URL if the user is authorized to see it. -- -- Built on top of 'isAuthorized'. This is useful for building page that only