cephfs: 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 0bafa2be8c
commit fad0cf7f1c

View File

@ -27,6 +27,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
}
// ErrNonStaticVolume is returned when a volume is detected as not being // ErrNonStaticVolume is returned when a volume is detected as not being
// statically provisioned // statically provisioned
type ErrNonStaticVolume struct { type ErrNonStaticVolume struct {
@ -38,6 +43,11 @@ func (e ErrNonStaticVolume) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrNonStaticVolume.
func (e ErrNonStaticVolume) Unwrap() error {
return e.err
}
// ErrVolumeNotFound is returned when a subvolume is not found in CephFS // ErrVolumeNotFound is returned when a subvolume is not found in CephFS
type ErrVolumeNotFound struct { type ErrVolumeNotFound struct {
err error err error
@ -47,3 +57,8 @@ type ErrVolumeNotFound struct {
func (e ErrVolumeNotFound) Error() string { func (e ErrVolumeNotFound) Error() string {
return e.err.Error() return e.err.Error()
} }
// Unwrap returns the encapsulated error of ErrVolumeNotFound.
func (e ErrVolumeNotFound) Unwrap() error {
return e.err
}