main :: IO ()
main = do
res <- try (mapM_ (callProcess "pandoc") [["--help"],["-eoc"],["-exois"],["--help"]]) :: IO (Either SomeException ())
case res of
Right a -> print "done"
Left e -> print "error"
in the above code, some of the argument for the command pandoc
are wrong and pandoc will throw errors. but I want my code to continue without stopping there and finish the mapM_
What Exception handling should I use?
The error I have is:
pandoc: unrecognized option `-e'
Try pandoc --help for more information.
"error"
Instead of try
ing your best to do a whole block of commands, have a block of commands that each try
their best. Change try (mapM_ foo bar)
into mapM_ (try . foo) bar
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments