aesiniath / http-streams

Haskell HTTP client library for use with io-streams
https://hackage.haskell.org/package/http-streams
BSD 3-Clause "New" or "Revised" License
50 stars 48 forks source link

Exception wrapping stream to catch attoparsec errors #4

Open istathar opened 11 years ago

istathar commented 11 years ago

In a comment on https://github.com/snapframework/io-streams/issues/3#issuecomment-12496548, @gregorycollins wrote:

Attoparsec has limited error reporting support. One thing you could do is write an exception wrapping stream that would catch any exception generated by read and wrap some kind of informative error message around it. More practically, what you will want to do for http-streams is to catch the exceptions you expect (ParseException being chief amongst them) and then do something smart about converting that error into a sensible http-streams exception.

This would be a Good Thing™.

AfC

gregorycollins commented 11 years ago

I meant that in your downstream code, if you receive an io-streams ParseException, that means you know where it came from and can re-wrap that to provide a useful error message to the user (BadHttpResponse or whatever).