-
Notifications
You must be signed in to change notification settings - Fork 7
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
Not getting the expected output #28
Comments
I did a bit of digging and landed in the
but since Not sure how to fix this, but happy to create a PR if you give me some guidelines. My gut feeling tells me that we should handle Also, I still have no clue how to display more than one "location" per error, kind of like a stack trace for a single element in the wrapped error stack... Not related to my issue, but I checkout out the project locally and I'm not sure why you're using the workspace feature to separate the tests. Seems like it makes testing more difficult, but that might just be my lack of experience with the workspace feature ... I'm curious to understand the reasoning. Hope this helps... |
Hey, I don't want to be rude or anything, but I would genuinely like to know if this project is dead? (since I got no feedback yet) |
Hey there! Definitely not dead, I was just on vacation ☀️ This library is running in production in a few codebases so it's still very much actively maintained. I'll give a proper read over your issue after a meeting today and get back to you, thank you in advance for the long and detailed write-up! |
Sorry for being pushy. I hope you had a great vacation! I'm happy to help with a PR if you provide some guidance on how to approach this, but we first need to see if what I'm proposing, aligns with the vision of your library. I just want to avoid spending time on something that won't get merged in the end. |
No worries! Okay so you're absolutely right, the desired behaviour is to have fault.New store a location as the root cause. I probably omitted this and opted to ship early! I'm glad you're keen to help get a solution merged!
So it seems the underlying error value is correct and does contain all the right data, but the flatten method is not treating the fundamental errors specially as you pointed out. I think my thinking here was to catch the case of non-Fault errors being located correctly? I'm not sure, but the test |
Each
Yeah this was me just keeping things separate, there is some discussion over here and my reasoning here. In my experience it just worked with the normal Go commands but that may be because I already had the project set up, happy to revert this if it's causing issues for new contributors. Out of interest, what problems did it cause? |
I understood the intent of having a less noisy solution. I'm just wondering about the example in the readme. If you only have one location per wrap, where does
About the workspace and separate test module, I was able to figure it out. For some reason I had set I'll try to play with the flatten test and maybe submit a PR in the next few days... Thanks for the context! |
Ah yes I think that comes from when a fault wrap has no message. The core Fault library does not any concept of wrapping with a message attached, so if you don't use the That snippet in the readme might be out of date though, So I think you can achieve that output by basically just calling The thinking here was partly to focus on Fault solving one problem only and delegating string messages to another library and also partly about not forcing the developer to add superfluous messages that don't add value. The vast majority of The obvious downside here is that 1. using extensions such as fmsg does add a bit more typing when writing the actual code and 2. just a location does assume quick source code access I did experiment with getting the caller's name via reflect but decided this was a bit too much complexity with no huge gains in developer experience. |
And regarding go.work I will remove this at some point to reduce friction! Thanks for the details regarding that! |
In terms of a failing test case that would cover what you're looking for, this seems logical: func TestFormatFaultChainWithoutMessages(t *testing.T) {
a := assert.New(t)
err := rootCause(4)
err = fault.Wrap(err)
err = fault.Wrap(err)
err = fault.Wrap(err)
err = fault.Wrap(err)
err = fault.Wrap(err)
a.Equal("fault root cause error", fmt.Sprintf("%s", err.Error()))
a.Equal("fault root cause error", fmt.Sprintf("%s", err))
a.Equal("fault root cause error", fmt.Sprintf("%v", err))
a.Regexp(`fault root cause error
\s+.+fault/tests/format_test.go:165
\s+.+fault/tests/format_test.go:166
\s+.+fault/tests/format_test.go:167
\s+.+fault/tests/format_test.go:168
\s+.+fault/tests/format_test.go:169
`, fmt.Sprintf("%+v", err))
} Currently this fails as the output is just:
But it should be:
If I'm understanding correctly. And looking at the behaviour, Flatten (again) is the culprit, it's filtering out errors that are only Fault containers in the |
I would argue that the first "location" should be in
Then if we do another test but with [ ... 1h later ... ] I changed the code a bit and created a branch in my fork. Turns out we don't need the new test, we have everything we need in existing tests, because we do plenty of Let me know what you think before I create a PR. |
yeah 100% this is definitely the original intention, it just got lost somewhere along the way somehow! As for the changes, it would be great to get the two different changes done separately (The multiple Thanks! |
Hey! If we're not doing multiple Locations, the alternative would be adding more I wrote the first PR to fix the original location of Waiting to hear back from you on the second part of this issue before creating another PR. |
Thanks for the first PR, huge improvement! So I opened up my local and found some unfinished work around multi-errors: type containermulti struct {
errs []error
}
func (f *containermulti) Unwrap() []error { return f.errs } I think the idea was to support the new Go v1.20 multi-error interface but I've not fully thought it through quite yet. As for the locations thing, multiple As long as the |
Not sure what the multi-errors has to do with this issues :) Ok, so this is my second try at fixing the locations with this new PR, without the multiple locations. I think it's pretty clean. I had to introduce intermediate I hope you like it! |
Thanks for the contribution! The double-wrap is fine I think, it solves the location problem. It did make me think about a common pattern I see in usage though and perhaps there's a better API for that. New issue for that though! |
@Southclaws are you planning to do a release soon? I would really like to use these changes :) |
Yeah I'll be doing a release soon! |
Hi. I love the lib idea and would love to use this, but I'm not getting the expected output.
The first thing I'm not seeing would be multiple stacktrace lines. In the readme, you give this example
where we see 2 lines for the "failed to call function" error stack (43 and 52), which leads me to believe this is possible.
The second thing I'm not seeing is the right line for my "fault root cause" error.
So what I'm seeing is
what I would love to see
Am I using it wrong?
Here is the example program for reference
Thank you
The text was updated successfully, but these errors were encountered: