Reputation: 51
The Haskell "zlib" library wraps the C library and lazily decompresses. The "decompress" function in this library can throw exceptions only catchable in the IO monad.
The type is this:
decompress :: ByteString -> ByteString
It uses the following:
foldDecompressStream L.Chunk L.Empty
(\_code msg -> error ("Codec.Compression.Zlib: " ++ msg))
Obviously it's possible for a data stream to be corrupted, which will cause an exception to be generated.
If I need to be catching multiple exceptions due to different causes, how can I tell one exception from another, other than by trying to match on the text (which has all sorts of negatives) ? I need to recover intelligently.
Upvotes: 5
Views: 224
Reputation: 23014
The way the code looks you can't do any better than match the string. You need to change something, maybe use foldDecopressionStream yourself?
Upvotes: 2