Skip to content
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

fix: avoid Errors call for nested Encode/Decode #781

Closed

Conversation

aleclarson
Copy link

Use a stack for Encode/Decode to detect when it‘s a nested call. If nested, the Errors function is not called, since the produced error would only be a fraction of the full JSON path. This change is beneficial for certain Transform usage, as described in #780.

Closes #780

Use a stack for Encode/Decode to detect when it‘s a nested call. If nested, the `Errors` function is **not** called, since the produced error would only be a fraction of the full JSON path. This change is beneficial for certain `Transform` usage, as described in sinclairzx81#780.

Closes sinclairzx81#780
@sinclairzx81
Copy link
Owner

@aleclarson Hey, thanks again for these PRs!

Give me a few days to review this and #777 as I'm currently unavailable this weekend. Will give this PR some thought, there may be a way to propagate the path into Encode/Decode, but might require an update to the TransformEncode, TransformDecode internal functions (making them work a bit like errors), but will need to review when I'm back.

I do think the Transform functions require a bit of rethinking in terms of error handling, and there may be cross over between this PR and #777. Will try get back to you early next week.

Thanks again!

@sinclairzx81
Copy link
Owner

@aleclarson Hiya,

I think this PR may be resolved by #791 where the thrown Error was added to the Transform{Encode|Decode}Error type which is now accessible via the error property. #791 also adds the path to this error type indicating which interior value caused the error to be thrown during Encode / Decode.

I think this resolves the original linked issue on #780 (which has since been closed, but relates specifically to obtaining error paths). However, can reopen and reinvestigate if I'm missing something with respect to the details around decodeStack provided on this implementation. If so, let's discuss via GH issues/discussions!

Thanks again for the PR, will close off this one for now.
All the best!
S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JSON path tracking to Encode/Decode
2 participants