pbrisbin / bugsnag-haskell

Bugsnag error reporter for Haskell
10 stars 7 forks source link

Store a single Exception in the Event #37

Closed pbrisbin closed 6 years ago

pbrisbin commented 6 years ago

This has been a source of great confusion for me. It makes no sense that the API accepts multiple Exceptions per Event, while at the same time:

Turns out, at least as far as I can tell, the multi-Exception interface is a Ruby-specific affordance. It's to support Exception#cause. Even that library is oriented in a single-Exception way, then it attempts to unwrap nested Exceptions at report-time. If it finds many levels, it needs a way to include them all, so the interface for the API was bent to accept exceptions (rather than accept Exception.cause :: Exception, which would've been both more Ruby-inspired and, IMO, a better general interface!).

Haskell doesn't have this notion (at least, not in any kind of first-class way). So we can basically take the same approach: pretend the whole world is single-Exception, then wrap it up as a list at report-time only.

The upside is we could avoid a documented caveat (updateException), an ErrorCall (bugsnagShouldNotify), and we should now be able to resolve Issue #26. The downside is we needed a manual ToJSON instance to perform the translation. No big deal. We could've avoided even this by using some kind of newtype, but that would've made the value-construction/use more cumbersome, so a poor trade-off.

pbrisbin commented 6 years ago

Doh. I already did this, was just missing the refactor.