-
Notifications
You must be signed in to change notification settings - Fork 79
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
Use custom error types and remove error downcasting #52
Comments
from zen: make sense to do before the audit, but shouldn't be a blocker |
I've spent some time investigating how to improve things here, but it turns out to be quite complex. In our current situation we have:
Some problems with this state:
Why do we have downcasting at all? There are some places where we can generate an ActorError with exit code but not propagate it directly, usually due to library code. E.g. the HAMT/AMT In #1322 I tried replacing a bunch of map and downcast patterns with more concise trait methods. It's on hold at present because a few tests fail due to changes in exit codes, as a code generated inside So what shall we do? Some options:
|
We should implement iteration with external iterators instead to fix this issue. I have a WIP patch locally that I can try to cleanup and ship if there's interest. That should remove a large part of this issue.
In many cases, I believe this is the right thing to do. Most of these errors should just be "illegal state".
IMO, this is the "correct" solution. It's just really annoying which is why most rust users just use crates like But yeah, we can do this where it matters. I.e.:
I like the idea of aborting early but... I'd prefer not to do this in all cases:
However, I'm concerned about using the runtime here as it may be hard to thread it through to the very bottom (and makes it harder to reason about what the code can do). Instead, I'd consider exposing it as a bare function that:
|
External iterators would be great. And then we could "give up" on doing better than "illegal state" for remaining hard cases. Your proposal re aborting sounds reasonable, and could clean up some boilerplate. In mechanism, why not just call the runtime's 'abort' anyway and have that panic (and catch it out the other side). Conditional compilation and static cling already causes headaches in this repo, I would rather avoid adding any more that we can. |
Currently, we have a lot of "anyhow" errors and rely on error downcasting to figure out the right exit code. Unfortunately, this makes it very difficult to figure out what the exit code should be.
Instead, we'd ideally:
The text was updated successfully, but these errors were encountered: