fix(binding): support custom unmarshaler for slices & arrays#4435
fix(binding): support custom unmarshaler for slices & arrays#4435crunchydosa123 wants to merge 8 commits intogin-gonic:masterfrom
Conversation
|
This PR aims to solve #4296 . Root Cause The trySetCustom function in binding/binding.go invokes: v.UnmarshalParam(val) However, since the method signature of UnmarshalParam does not include the field name, custom unmarshallers cannot attach field context to their errors. Solution This PR wraps the error returned by UnmarshalParam with a new structured error type: type FieldError struct { trySetCustom() is updated to append the field name when returning errors from BindUnmarshaler. This ensures that the standard error propagation chain includes the field name, resulting in user-friendly and debuggable error messages. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4435 +/- ##
==========================================
- Coverage 99.21% 98.55% -0.66%
==========================================
Files 42 44 +2
Lines 3182 2984 -198
==========================================
- Hits 3157 2941 -216
- Misses 17 28 +11
- Partials 8 15 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request Checklist
Please ensure your pull request meets the following requirements:
masterbranch.docs/doc.md.Thank you for contributing!