mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-23 21:40:20 +00:00
util: 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:
parent
6d6b5bab3c
commit
8effa0cd3e
@ -32,6 +32,11 @@ func (e ErrKeyNotFound) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the encapsulated error.
|
||||
func (e ErrKeyNotFound) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// ErrObjectExists is returned when named omap is already present in rados
|
||||
type ErrObjectExists struct {
|
||||
objectName string
|
||||
@ -43,6 +48,11 @@ func (e ErrObjectExists) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the encapsulated error.
|
||||
func (e ErrObjectExists) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// ErrObjectNotFound is returned when named omap is not found in rados
|
||||
type ErrObjectNotFound struct {
|
||||
oMapName string
|
||||
@ -54,6 +64,11 @@ func (e ErrObjectNotFound) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the encapsulated error.
|
||||
func (e ErrObjectNotFound) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// ErrSnapNameConflict is generated when a requested CSI snap name already exists on RBD but with
|
||||
// different properties, and hence is in conflict with the passed in CSI volume name
|
||||
type ErrSnapNameConflict struct {
|
||||
@ -66,6 +81,11 @@ func (e ErrSnapNameConflict) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the encapsulated error.
|
||||
func (e ErrSnapNameConflict) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// NewErrSnapNameConflict returns a ErrSnapNameConflict error when CSI snap name already exists.
|
||||
func NewErrSnapNameConflict(name string, err error) ErrSnapNameConflict {
|
||||
return ErrSnapNameConflict{name, err}
|
||||
@ -82,6 +102,11 @@ func (e ErrPoolNotFound) Error() string {
|
||||
return e.Err.Error()
|
||||
}
|
||||
|
||||
// Unwrap returns the encapsulated error.
|
||||
func (e ErrPoolNotFound) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
// NewErrPoolNotFound returns a new ErrPoolNotFound error.
|
||||
func NewErrPoolNotFound(pool string, err error) ErrPoolNotFound {
|
||||
return ErrPoolNotFound{pool, err}
|
||||
|
Loading…
Reference in New Issue
Block a user