From fad0cf7f1c4bcfd297d3097959dec6802d25afc1 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 30 Jun 2020 08:43:24 +0200 Subject: [PATCH] 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 --- internal/cephfs/errors.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/cephfs/errors.go b/internal/cephfs/errors.go index 4ae376e53..7cacf72a8 100644 --- a/internal/cephfs/errors.go +++ b/internal/cephfs/errors.go @@ -27,6 +27,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 +} + // ErrNonStaticVolume is returned when a volume is detected as not being // statically provisioned type ErrNonStaticVolume struct { @@ -38,6 +43,11 @@ func (e ErrNonStaticVolume) Error() string { 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 type ErrVolumeNotFound struct { err error @@ -47,3 +57,8 @@ type ErrVolumeNotFound struct { func (e ErrVolumeNotFound) Error() string { return e.err.Error() } + +// Unwrap returns the encapsulated error of ErrVolumeNotFound. +func (e ErrVolumeNotFound) Unwrap() error { + return e.err +}