Conversation
|
@alecthomas Any chance this could be merged in? |
|
What does "which are a bit trickier to work with than regular errors" mean? The only issue I've had with them is the formatting, but other than that they seem totally fine. |
|
Exactly. When serializing them to JSON for logging, I get now unnecessary nested errors. Similarly, when printing them to the console, recursively, there is unnecessary extra level because of this join. So yea, |
|
Mmm...that doesn't make much sense does it? errors.Join() can't be JSON marshalled anyway, and in the case where there is more than one error you're going to have to deal with it anyway? I don't think this makes sense to be in kong, vs. wherever you're consuming the error. Happy to reconsider if you have a compelling reason. |
|
Oh, I have whole errors package which supports JSON marshaling to JSON of arbitrary errors and trees of errors, it also extracts stack traces and other potential extra metadata/details, etc. So yes, errors can be JSON marhaled. Same for formatting. So having one unnecessary join in-between, it makes things ugly. I can of course special-case it on my side. But from looking at Kong's code it seems pretty trivial to fix this. It is also not in any critical path. Check is simple. So I decided to contribute it here. |
|
I would claim that stdlib's |
|
I investigated. The main issue is that I use pattern with Kong's So in summary, I would assume |
Standard library's
errors.Joinalways joins errors which are a bit trickier to work with than regular errors. So adding a simple check to make sureerrors.Joinis really necessary.