git.iko.soy/typeable/octopod
on master help sign in
Don't show empty errors in Web UI (#158)
commita6019f4370542991539a0eaf7757cb75899739ac authoriko <ilyakooo0@gmail.com> dateThu 9 Dec 2021, 16:20 (5 years ago) parent041c1ea
1 file changed+7−2
octopod-frontend/src/Frontend/Utils.hs+7−2
octopod-frontend/src/Frontend/Utils.hs+7−2
@@ -56,7 +56,7 @@ import Data.Maybe (fromMaybe, isJust, isNothing)
5656import Data.Monoid
5757import Data.Set (Set)
5858import qualified Data.Set as S
59−import Data.Text as T (Text, null, pack)
59+import Data.Text as T (Text, null, pack, strip)
6060import Data.Text.Search
6161import Data.These
6262import Data.Time
@@ -477,9 +477,14 @@ wrapRequestErrors f = mdo
477477 (x, ev :: Event t (PatchMap Unique Text)) <- runEventWriterT $
478478 f $ \reqEv -> do
479479 k <- liftIO newUnique
480− tellEvent $ fmapCheap (PatchMap . M.singleton k . reqErrorBody) reqEv
480+ tellEvent $ fmap (PatchMap . M.singleton k . fmap catchEmptyErrors . reqErrorBody) reqEv
481481 pure $ fmapMaybeCheap reqSuccess reqEv
482482 pure x
483+ where
484+ catchEmptyErrors t
485+ | (T.null . T.strip) t =
486+ "Something went wrong, but no explanation was provided."
487+ catchEmptyErrors t = t
483488
484489-- | The widget used to display errors.
485490errorHeader ::