rbd: add Unwrap() to error types

See-also: https://github.com/golang/go/wiki/ErrorValueFAQ#i-have-a-type-that-implements-error-and-holds-a-nested-error-how-should-i-adapt-it-to-the-new-features
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-30 08:43:24 +02:00 committed by mergify[bot]
parent fad0cf7f1c
commit 6d6b5bab3c

View File

@ -27,6 +27,11 @@ func (e ErrImageNotFound) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrImageNotFound.
func (e ErrImageNotFound) Unwrap() error {
return e.err
}
// ErrSnapNotFound is returned when snap name passed is not found in the list of snapshots for the // ErrSnapNotFound is returned when snap name passed is not found in the list of snapshots for the
// given image // given image
type ErrSnapNotFound struct { type ErrSnapNotFound struct {
@ -39,6 +44,11 @@ func (e ErrSnapNotFound) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrSnapNotFound.
func (e ErrSnapNotFound) Unwrap() error {
return e.err
}
// ErrVolNameConflict is generated when a requested CSI volume name already exists on RBD but with // ErrVolNameConflict is generated when a requested CSI volume name already exists on RBD but with
// different properties, and hence is in conflict with the passed in CSI volume name // different properties, and hence is in conflict with the passed in CSI volume name
type ErrVolNameConflict struct { type ErrVolNameConflict struct {
@ -51,6 +61,11 @@ func (e ErrVolNameConflict) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrVolNameConflict.
func (e ErrVolNameConflict) Unwrap() error {
return e.err
}
// ErrInvalidVolID is returned when a CSI passed VolumeID does not conform to any known volume ID // ErrInvalidVolID is returned when a CSI passed VolumeID does not conform to any known volume ID
// formats // formats
type ErrInvalidVolID struct { type ErrInvalidVolID struct {
@ -62,6 +77,11 @@ func (e ErrInvalidVolID) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrInvalidVolID.
func (e ErrInvalidVolID) Unwrap() error {
return e.err
}
// ErrMissingStash is returned when the image metadata stash file is not found // ErrMissingStash is returned when the image metadata stash file is not found
type ErrMissingStash struct { type ErrMissingStash struct {
err error err error
@ -72,6 +92,11 @@ func (e ErrMissingStash) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrMissingStash.
func (e ErrMissingStash) Unwrap() error {
return e.err
}
// ErrFlattenInProgress is returned when flatten is inprogess for an image // ErrFlattenInProgress is returned when flatten is inprogess for an image
type ErrFlattenInProgress struct { type ErrFlattenInProgress struct {
err error err error
@ -81,3 +106,8 @@ type ErrFlattenInProgress struct {
func (e ErrFlattenInProgress) Error() string { func (e ErrFlattenInProgress) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrFlattenInProgress.
func (e ErrFlattenInProgress) Unwrap() error {
return e.err
}