structerr: Extract metadata from joined errors
The structerr.ExtractMetadata()
function extracts metadata from the
specified error. If the error is wrapped, metadata for chained errors is
also extracted. Wrapped errors implement Unwrap() error
to allow
chained erros to be uncovered.
As of Go version 1.20, errors can be joined with the errors.Join()
function. Since joined errors internally reference multiple errors, to
be unwrapped, joined errors implement Unwrap() []error
instead.
To support extraction of error metadata when joined errors exist in the
chain, structerr.ExtractMetadata()
is updated to recursively unwrap
standard errors and joined errors.