2022-02-28 10:56:46 +00:00
|
|
|
package client
|
|
|
|
|
2022-06-27 07:39:20 +00:00
|
|
|
import (
|
2023-05-17 09:07:01 +00:00
|
|
|
"errors"
|
2022-08-05 07:56:49 +00:00
|
|
|
"fmt"
|
2022-06-27 07:39:20 +00:00
|
|
|
)
|
|
|
|
|
2023-05-15 03:45:06 +00:00
|
|
|
var (
|
2023-05-17 09:07:01 +00:00
|
|
|
ErrMissingContainer = errors.New("missing container")
|
|
|
|
ErrMissingObject = errors.New("missing object")
|
|
|
|
ErrMissingAccount = errors.New("missing account")
|
|
|
|
ErrMissingEACL = errors.New("missing eACL table")
|
|
|
|
ErrMissingEACLContainer = errors.New("missing container in eACL table")
|
|
|
|
ErrMissingAnnouncements = errors.New("missing announcements")
|
|
|
|
ErrZeroRangeLength = errors.New("zero range length")
|
|
|
|
ErrMissingRanges = errors.New("missing ranges")
|
|
|
|
ErrZeroEpoch = errors.New("zero epoch")
|
|
|
|
ErrMissingTrusts = errors.New("missing trusts")
|
|
|
|
ErrMissingTrust = errors.New("missing trust")
|
|
|
|
|
|
|
|
ErrUnexpectedReadCall = errors.New("unexpected call to `Read`")
|
|
|
|
|
2023-05-15 03:45:06 +00:00
|
|
|
errMissingResponseField missingResponseFieldErr
|
|
|
|
)
|
|
|
|
|
|
|
|
type missingResponseFieldErr struct {
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e missingResponseFieldErr) Error() string {
|
|
|
|
return fmt.Sprintf("missing %s field in the response", e.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e missingResponseFieldErr) Is(target error) bool {
|
|
|
|
switch target.(type) {
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
case missingResponseFieldErr, *missingResponseFieldErr:
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-05 07:56:49 +00:00
|
|
|
// returns error describing missing field with the given name.
|
|
|
|
func newErrMissingResponseField(name string) error {
|
2023-05-15 03:45:06 +00:00
|
|
|
return missingResponseFieldErr{name: name}
|
2022-08-05 07:56:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// returns error describing invalid field (according to the NeoFS protocol)
|
|
|
|
// with the given name and format violation err.
|
|
|
|
func newErrInvalidResponseField(name string, err error) error {
|
|
|
|
return fmt.Errorf("invalid %s field in the response: %w", name, err)
|
|
|
|
}
|