Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix error reporting in CLI backend

  • Loading branch information...
commit d85596b519f0842413f12958e4db06b1fa9e9f8a 1 parent c059123
@jaspervdj jaspervdj authored
Showing with 6 additions and 8 deletions.
  1. +6 −8 digestive-functors/src/Text/Digestive/Cli.hs
View
14 digestive-functors/src/Text/Digestive/Cli.hs
@@ -60,16 +60,15 @@ prompt :: String -- ^ Description
prompt descr = Form $ do
id' <- getFormId
inp <- getFormInput
+ range <- getFormRange
let v :: [(FormRange, String)] -> PromptView
- v errs = PromptView [FieldItemSingle id' descr (map snd matching)]
+ v errs = PromptView [FieldItemSingle id' descr matching]
where
-- Only errors which apply specifically to this item
- matching :: [(FormRange, String)]
- matching = filter (flip isSubRange range . fst) errs
- range = unitRange id'
+ matching = retainErrors range errs
result = case inp of
- Just x -> Ok x
- Nothing -> Error [(range, "No input")]
+ Just x -> Ok x
+ Nothing -> Error [(range, "No input")]
return (View v, result)
-- | Convert a prompt for a single item into a prompt for multiple items
@@ -92,8 +91,7 @@ promptList descr prmpt = Form $ do
-- the contained items are used to enter in a single User.)
let vstart errs = PromptView [item]
where
- item = FieldItemMultiStart id' descr (map snd matching)
- matching = filter (flip isSubRange range . fst) errs
+ item = FieldItemMultiStart id' descr $ retainErrors range errs
vend _ = PromptView [FieldItemMultiEnd]
return (View vstart `mappend` v `mappend` View vend, r1)
where
Please sign in to comment.
Something went wrong with that request. Please try again.