-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor Flatten to first flatten the tree and then filter the results #16
Comments
I have a modified version of flatten in my repo (https://github.com/spearson78/fault/tree/floc) that doesn't have look ahead but is functionally equivalent. I was trying to make auto generated location optional so that a library can generate an error with a location that corresponds to the caller rather than a random line of code in the library. This reduces the amount of wrapping needed in user code. |
This would be good to explore as a solution. I'm going to make some changes to the flatten call soon so it's at least easier to make simple changes/additions to. |
Check out the latest release (v0.5.0) where I've rewritten Flatten to be more smart about duplicate nested error messages. There's still some work to do around locations, it may be worth storing a full stack trace with each error step and unpacking the most logical frame when the error is flattened. Anyway, can move discussion for this to another issue. |
Currently, the implementation of Flatten is a bit more complex than it needs to be. This is partly due to the way the loop mutates
next
in a couple of places and also doubly callsUnwrap
and re-assignserr
twice.This could be simplified by first running the
Unwrap
loop to product a simple slice of errors. Then, once there's a slice, it would be easier to do the filtering with lookahead/lookbehind instead of (what is essentially) double step/next iterations etc.The text was updated successfully, but these errors were encountered: