diff --git a/internal/rbd/errors.go b/internal/rbd/errors.go index a2d32bcd9..2675562ae 100644 --- a/internal/rbd/errors.go +++ b/internal/rbd/errors.go @@ -27,6 +27,11 @@ func (e ErrImageNotFound) Error() string { 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 // given image type ErrSnapNotFound struct { @@ -39,6 +44,11 @@ func (e ErrSnapNotFound) Error() string { 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 // different properties, and hence is in conflict with the passed in CSI volume name type ErrVolNameConflict struct { @@ -51,6 +61,11 @@ func (e ErrVolNameConflict) Error() string { 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 // formats type ErrInvalidVolID struct { @@ -62,6 +77,11 @@ func (e ErrInvalidVolID) Error() string { 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 type ErrMissingStash struct { err error @@ -72,6 +92,11 @@ func (e ErrMissingStash) Error() string { 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 type ErrFlattenInProgress struct { err error @@ -81,3 +106,8 @@ type ErrFlattenInProgress struct { func (e ErrFlattenInProgress) Error() string { return e.err.Error() } + +// Unwrap returns the encapsulated error of ErrFlattenInProgress. +func (e ErrFlattenInProgress) Unwrap() error { + return e.err +}