It would be useful for Atlas Data Lake if the errors returned by calls to bson.UnmarshalWithRegistry were structured or configurable so that we could extract certain information that we want to expose to the user (like the tag of the field that errored), and hide our internal implementation details from the user (like the name of the struct that could not be decoded).
For example, as illustrated in MHOUSE-1425: when we decode a user-supplied command, if the command is not structured properly, we'll get an error from bson.UnmarshalWithRegistry like this:
The trouble is that we don't want to expose our internal struct types, and as a result we have to throw out this whole error message, leaving the user with something generic like "failed to parse command".
So either we'd like to be able to specify that the error message should not include the struct field name. Or even better, it would be great if we got back a structured error that allowed us to manually pull out the tag, struct field name, and given type so that we can craft our own error message.
I don't quite understand the decoding logic well enough to know how big / possible of an ask this is so let me know. It's not mission critical for ADL, but would definitely result in a better experience for our users.