Skip to content

Commit

Permalink
refactor WrapError 2
Browse files Browse the repository at this point in the history
  • Loading branch information
quartzmo committed Nov 7, 2022
1 parent 926b2ed commit e96b207
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/gensupport/error.go
Expand Up @@ -11,13 +11,12 @@ import (
"google.golang.org/api/googleapi"
)

// WrapError creates an [apierror.APIError] from err (one that does not wrap
// err), wraps it in err, and returns err. If err is not a [googleapi.Error]
// (or a [google.golang.org/grpc/status.Status]), it returns err without
// modification.
// WrapError creates an [apierror.APIError] from err, wraps it in err, and
// returns err. If err is not a [googleapi.Error] (or a
// [google.golang.org/grpc/status.Status]), it returns err without modification.
func WrapError(err error) error {
apiError, ok := apierror.ParseError(err, false)
var herr *googleapi.Error
apiError, ok := apierror.ParseError(err, false)
if ok && errors.As(err, &herr) {
herr.Wrap(apiError)
}
Expand Down

0 comments on commit e96b207

Please sign in to comment.