[Haskell-cafe] Decorating exceptions with backtrace information

Henning Thielemann lemming at henning-thielemann.de
Tue May 12 20:55:08 UTC 2020


On Fri, 8 May 2020, Niklas Hambüchen wrote:

>> What are "unintended exceptions"?
>> What is an example of an "unintended exception"?
>
> A recent example from my production server:
>
>    hPutBuf: resource vanished (Broken pipe)


Ok, I lookup the Haddock comment of hPutBuf and it says:

"This operation may fail with:

* ResourceVanished if the handle is a pipe or socket, and the reading end 
is closed."

That is, ResourceVanished is part of the public interface and in no way 
unexpected (or what "unintended" may be). I would prefer to make this 
explicit in the type of hPutBuf:

hPutBuf ::
    (ResourceVanishedException e) =>
    Handle -> Ptr a -> Int -> ExceptT e IO ()

Now, what do you intend to do with the call-stack? Isn't it something you 
can attach to the e value?


More information about the Haskell-Cafe mailing list