Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. better exception handling (Miro Karpis) ---------------------------------------------------------------------- Message: 1 Date: Wed, 23 Oct 2013 23:11:32 +0200 From: Miro Karpis <miroslav.kar...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <Beginners@haskell.org> Subject: [Haskell-beginners] better exception handling Message-ID: <cajnnbxegthc8u8hvg5ocv7bc6k-xijdgnr6fe3ivf6_ei2j...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Please, can you help me with following?... I have a working code but am not very happy with the error handling in "updateStocks" function. It does what it should, but I would like to implement some kind of guards. Problem is that it always ends it some error + am not sure if I can use guards in inside defined variable. Pls. what would you suggest? httpExceptionHandler :: HttpException -> IO L.ByteString httpExceptionHandler e = (putStrLn "Error: simpleHttp returned exception ") >> (return L.empty) getStocks :: String -> IO L.ByteString getStocks url = (simpleHttp url) `X.catch` httpExceptionHandler updateStocks :: IO String updateStocks = do yqlResult <- getStocks testQuery case yqlResult of x | x == L.empty -> return "return exception" | otherwise -> return "here I will call another function" thanks, m. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20131023/f808cadc/attachment-0001.html> ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 64, Issue 36 *****************************************