From a6019f4370542991539a0eaf7757cb75899739ac Mon Sep 17 00:00:00 2001 From: iko Date: Thu, 9 Dec 2021 16:20:14 +0300 Subject: [PATCH] Don't show empty errors in Web UI (#158) --- octopod-frontend/src/Frontend/Utils.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/octopod-frontend/src/Frontend/Utils.hs b/octopod-frontend/src/Frontend/Utils.hs index 7a9f711..a933d49 100644 --- a/octopod-frontend/src/Frontend/Utils.hs +++ b/octopod-frontend/src/Frontend/Utils.hs @@ -56,7 +56,7 @@ import Data.Maybe (fromMaybe, isJust, isNothing) import Data.Monoid import Data.Set (Set) import qualified Data.Set as S -import Data.Text as T (Text, null, pack) +import Data.Text as T (Text, null, pack, strip) import Data.Text.Search import Data.These import Data.Time @@ -477,9 +477,14 @@ wrapRequestErrors f = mdo (x, ev :: Event t (PatchMap Unique Text)) <- runEventWriterT $ f $ \reqEv -> do k <- liftIO newUnique - tellEvent $ fmapCheap (PatchMap . M.singleton k . reqErrorBody) reqEv + tellEvent $ fmap (PatchMap . M.singleton k . fmap catchEmptyErrors . reqErrorBody) reqEv pure $ fmapMaybeCheap reqSuccess reqEv pure x + where + catchEmptyErrors t + | (T.null . T.strip) t = + "Something went wrong, but no explanation was provided." + catchEmptyErrors t = t -- | The widget used to display errors. errorHeader ::