Description
Is your feature request related to a problem? Please describe.
Custom unmarshalers do not provide consistent source line/column context in error messages. Only the ast.Node
unmarshaler interface is able to provide source line/column information for our error messages. Ideally we would have consistent error formatting with a trace of source yaml line/column numbers just as we do for any other YAML decode errors.
Describe the solution you'd like
Add a new error type, UnmarshalerError
which is used to wrap any errors returned from decodeByUnmarshaler
. This should just implement the usual Error
interface using the friendly FormatError
.
Describe alternatives you've considered
For every type implementing its own unmarshaler, we would need to add or modify an UnmarshalYAML implementation to follow the ast.Node
interface, and as the caller implement a new error type implementing the internal Error
interface for these unmarshalers to return.
We would have to wrap/embed any external types in a new type since the customUnmarshalerMap
only supports the []byte
unmarshaler interface, not ast.Node
.