Permalink
Browse files

Defer error handling of runInputForm to user code.

  • Loading branch information...
elisehuard committed Jan 30, 2014
1 parent c0e366b commit 12897ae5a06c04a62124bf457527c31be65cf62b
Showing with 3 additions and 3 deletions.
  1. +3 −3 yesod-form/Yesod/Form/Input.hs
@@ -65,12 +65,12 @@ runInputGet (FormInput f) = do
toMap :: [(Text, a)] -> Map.Map Text [a]
toMap = Map.unionsWith (++) . map (\(x, y) -> Map.singleton x [y])
-runInputPost :: MonadHandler m => FormInput m a -> m a
+runInputPost :: MonadHandler m => FormInput m a -> m (FormResult a)
runInputPost (FormInput f) = do
(env, fenv) <- liftM (toMap *** toMap) runRequestBody
m <- getYesod
l <- languages
emx <- f m l env fenv
case emx of
- Left errs -> invalidArgs $ errs []
- Right x -> return x
+ Left errs -> return $ FormFailure (errs [])
+ Right x -> return (FormSuccess x)

0 comments on commit 12897ae

Please sign in to comment.