apierror: simplify extraction of custom errors #212
Labels
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Within apierror, the ErrDetails type holds decoded values from an rpc status:
https://pkg.go.dev/github.com/googleapis/gax-go/v2/apierror#ErrDetails
Custom messages such as service-specific custom error types end up in the Unknown slice of ErrDetails, which is a slice of empty interface types. It would be beneficial to provide a utility mechanism for extracting a message of a given type from the ErrDetails.
By way of example, the bigquerystorage service has a StorageError type:
https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1#StorageError
Being able to more easily extract this from APIError would be lovely. Perhaps something like this might make sense?
Also happy to make the change if this seems reasonable.
cc @noahdietz @quartzmo
The text was updated successfully, but these errors were encountered: