Discussion: adding displayException to Exception class

Simon Hengel sol at typeful.net
Wed Oct 29 02:22:02 UTC 2014


Hi Michael,

> > Personally, I think it will be nice to be able to quickly identify the
> > constructor of the exception.  Currently one has Google for the error
> > message and hope for the best.
>
> Thank you for pointing that out. As it happens, that's the exact
> conversation Chris and I had which led to this email ;).

Same thought here, one of my main complaints about the current state of
exceptions is that the default exception handler gives you no hint about
the type of uncaught exceptions.

For me uncaught exceptions are a programming error and I want output
that helps me as a programmer to fix that programming error.  I don't
care about "user-friendly data display" here.

I think given the nature of hierarchical exceptions there is currently
no generic way to show the exception type if the exception is at depth <
1 in the tree (for uncaught exceptions in Hspec I use the code at [1],
which is better than using show but still not ideal).

For this reason I *always* derive the Show instance if I define an
exception type + I would prefer if Show instances for other exceptions
would be derived, too (where possible).

Would this proposal address this issue?  How exactly?  Could we just fix
the (in my perspective) "broken" Show instances for standard exceptions
instead?

Cheers,
Simon

[1] https://github.com/hspec/hspec/blob/03651daf5b9eee4ca9e3c3941743519cda4768ab/hspec-core/src/Test/Hspec/Util.hs#L23


More information about the Libraries mailing list