-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carry the exception #461
Carry the exception #461
Conversation
Looks like a sensible change, and I'd be OK with the breakage. This should likely come along with a major version bump and changelog entry explaining the change. Ignoring PVP noise, I'm guessing this won't actually break much code in the wild. Did you want to do more testing with this branch before we make a release? |
@parsonsmatt Still hoping to take this, or can I take it over? Came looking for exactly this. |
FWIW this is useful for more than debugging, unless you include detailed instrumentation in prod "debugging". I want to have resource-scoped events that store exception information when they exit unsuccessfully. |
Instead of |
ReleaseExceptionWith (E.SomeException e0) == ReleaseExceptionWith (E.SomeException e1) = | ||
case typeOf e0 == typeOf e1 of | ||
True -> | ||
show e0 == show e1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expected to be right? 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used it a bunch and it uhhh does mostly work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until future changes to GHC render the backtrace in show?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, those would only be able to work on the show :: SomeException -> String
type, since SomeException
carries the implicit parameters for the stack trace. This uses the Show a
that is implied by the Exception a
dictionary that is packed in the GADT.
I think I was able to use this to debug the issue in |
@snoyberg Still open to this? OK at add |
Making weird carve outs for |
It's not a carve-out for
I'm happy to finish up any of 2-4 if they'd be welcome. |
I’m very much on the fence on this. I understand the motivation for this. However, adding a breaking change to a long-stable library when there are still a few open design questions is a bigger deal than I initially recognized. Are there no ways to achieve the same thing you’re doing here with the current API? |
My use case is a generic event-oriented instrumentation library. My typical usage is the But For a less intrusive option, perhaps we can add a way to add a |
OK, I've given it some thought, and the change does seem reasonable. I want to propose a slight modification to (4) above: would it be possible to keep the current data constructors unmodified and add a new data constructor that captures the It could also be that I'm being overly worried, and the pattern synonyms included here do the heavy lifting for us. I'm simply inexperienced with using pattern synonyms at all. For me, the guiding principle is: let's do this in a way that minimizes impact on end users as much as possible. |
@snoyberg I'm not sure if this can be done with clever use of pattern synonyms, but if we're trying to minimize impact then I think we'd want (modulo naming bikeshedding):
If 2 isn't quite possible as described, then probably we can do:
I can look into whether either of these is possible, if you like the approach |
No strong opinion from me, I noticed the pattern synonym in this existing PR, but I really don't understand the impact on backwards compat. |
I don't think For backwards compatibility, the current code allows you to continue pattern matching on In hindsight, I'm not really in favor of having a |
@parsonsmatt Ah, I hadn't looked at the code but I assumed there were instances where you legitimately couldn't get the exception. If that's not the case then yeah we should keep the code as it is. What did you mean by:
? |
I am not sure what I was thinking. It looks like we lost |
Ah, instances for |
Supercedes and resolves snoyberg#461. Fixes snoyberg#460. Co-authored-by: Shea Levy <[email protected]> Co-authored-by: parsonsmatt <[email protected]>
@parsonsmatt Let me know if you want me to remove your |
Supercedes and resolves snoyberg#461. Fixes snoyberg#460. Co-authored-by: Shea Levy <[email protected]> Co-authored-by: parsonsmatt <[email protected]>
Supercedes and resolves snoyberg#461. Fixes snoyberg#460. Co-authored-by: Shea Levy <[email protected]> Co-authored-by: parsonsmatt <[email protected]>
Supercedes and resolves snoyberg#461. Fixes snoyberg#460. Co-authored-by: Shea Levy <[email protected]> Co-authored-by: parsonsmatt <[email protected]>
Supercedes and resolves snoyberg#461. Fixes snoyberg#460. Co-authored-by: Shea Levy <[email protected]> Co-authored-by: parsonsmatt <[email protected]>
This PR amends
ReleaseException
to carry the exception that was thrown.This is a pretty big breaking change unfortunately - lots of instances are removed. I can probably recover some of them, especially if I use
Maybe SomeException
and just dumpNothing
in for the bad ones.Probably only useful for debugging.
Fixes #460