forked from TrueCloudLab/frostfs-sdk-go
[#140] client: Specify status errors of Client
methods
Extend docs with supported status returns. Add several helper functions which allow to check the particular status. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
12aa7ae144
commit
2a0b7b6b40
8 changed files with 87 additions and 10 deletions
42
client/errors.go
Normal file
42
client/errors.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package client
|
||||
|
||||
import apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
|
||||
|
||||
// IsErrContainerNotFound checks if err corresponds to NeoFS status
|
||||
// return corresponding to missing container.
|
||||
func IsErrContainerNotFound(err error) bool {
|
||||
switch err.(type) {
|
||||
default:
|
||||
return false
|
||||
case
|
||||
apistatus.ContainerNotFound,
|
||||
*apistatus.ContainerNotFound:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// IsErrObjectNotFound checks if err corresponds to NeoFS status
|
||||
// return corresponding to missing object.
|
||||
func IsErrObjectNotFound(err error) bool {
|
||||
switch err.(type) {
|
||||
default:
|
||||
return false
|
||||
case
|
||||
apistatus.ObjectNotFound,
|
||||
*apistatus.ObjectNotFound:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// IsErrObjectAlreadyRemoved checks if err corresponds to NeoFS status
|
||||
// return corresponding to already removed object.
|
||||
func IsErrObjectAlreadyRemoved(err error) bool {
|
||||
switch err.(type) {
|
||||
default:
|
||||
return false
|
||||
case
|
||||
apistatus.ObjectAlreadyRemoved,
|
||||
*apistatus.ObjectAlreadyRemoved:
|
||||
return true
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue