Extract detailed error information
Hi there,
I'm currently using mapstructure for an API, to convert a map[string]interface{} extracted from user inputs into a structure.
The main use-case is working very well, however I would like to generate my own error messages instead of directly using the error returned by the library.
The required information would be:
- which field failed to be converted
- what was the expected type
- what was the type of the field that failed to be converted
From what I've seen, this is currently not easily done with mapstructure.
Do you think it would be possible to find those information after a call to Decode without having to scan the error message string?
I’d be open to changing the error result into a rich error type, I think that’d be the easiest way.
Thanks for your answer. :+1: I will be working on a PR to add some error types, corresponding to my use case.