diff --git a/client/client.go b/client/client.go index ce0c9ee..aa873e5 100644 --- a/client/client.go +++ b/client/client.go @@ -74,6 +74,10 @@ func (c *Client) Init(prm PrmInit) { // One-time method call during application start-up stage (after Init ) is expected. // Calling multiple times leads to undefined behavior. // +// Return client errors: +// - [ErrMissingServer] +// - [ErrNonPositiveTimeout] +// // See also Init / Close. func (c *Client) Dial(prm PrmDial) error { if prm.endpoint == "" { diff --git a/client/errors.go b/client/errors.go index bd9d7e2..da55c52 100644 --- a/client/errors.go +++ b/client/errors.go @@ -6,23 +6,38 @@ import ( ) var ( - ErrMissingServer = errors.New("server address is unset or empty") + // ErrMissingServer is returned when server endpoint is empty in parameters. + ErrMissingServer = errors.New("server address is unset or empty") + // ErrNonPositiveTimeout is returned when any timeout is below zero in parameters. ErrNonPositiveTimeout = errors.New("non-positive timeout") - ErrMissingContainer = errors.New("missing container") - ErrMissingObject = errors.New("missing object") - ErrMissingAccount = errors.New("missing account") - ErrMissingEACL = errors.New("missing eACL table") + // ErrMissingContainer is returned when container is not provided. + ErrMissingContainer = errors.New("missing container") + // ErrMissingObject is returned when object is not provided. + ErrMissingObject = errors.New("missing object") + // ErrMissingAccount is returned when account/owner is not provided. + ErrMissingAccount = errors.New("missing account") + // ErrMissingEACL is returned when eACL table is not provided. + ErrMissingEACL = errors.New("missing eACL table") + // ErrMissingEACLContainer is returned when container info is not provided in eACL table. ErrMissingEACLContainer = errors.New("missing container in eACL table") + // ErrMissingAnnouncements is returned when announcements are not provided. 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") + // ErrZeroRangeLength is returned when range parameter has zero length. + ErrZeroRangeLength = errors.New("zero range length") + // ErrMissingRanges is returned when empty ranges list is provided. + ErrMissingRanges = errors.New("missing ranges") + // ErrZeroEpoch is returned when zero epoch is provided. + ErrZeroEpoch = errors.New("zero epoch") + // ErrMissingTrusts is returned when empty slice of trusts is provided. + ErrMissingTrusts = errors.New("missing trusts") + // ErrMissingTrust is returned when empty trust is not provided. + ErrMissingTrust = errors.New("missing trust") + // ErrUnexpectedReadCall is returned when we already got all data but truing to get more. ErrUnexpectedReadCall = errors.New("unexpected call to `Read`") + // ErrSign is returned when unable to sign service message. ErrSign SignError errMissingResponseField missingResponseFieldErr @@ -56,22 +71,27 @@ func newErrInvalidResponseField(name string, err error) error { return fmt.Errorf("invalid %s field in the response: %w", name, err) } +// SignError wraps another error with reason why sign process was failed. type SignError struct { err error } +// NewSignError is a constructor for [SignError]. func NewSignError(err error) SignError { return SignError{err: err} } +// Error implements the error interface. func (e SignError) Error() string { return fmt.Sprintf("sign: %v", e.err) } +// Unwrap implements the error interface. func (e SignError) Unwrap() error { return e.err } +// Is implements interface for correct checking current error type with [errors.Is]. func (e SignError) Is(target error) bool { switch target.(type) { default: diff --git a/client/netmap.go b/client/netmap.go index 7d955f5..27614c1 100644 --- a/client/netmap.go +++ b/client/netmap.go @@ -41,6 +41,8 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo { // Any client's internal or transport errors are returned as `error`, // see [apistatus] package for NeoFS-specific error types. // +// Context is required and must not be nil. It is used for network communication. +// // Exactly one return value is non-nil. Server status return is returned in ResEndpointInfo. // Reflects all internal errors in second return value (transport problems, response processing, etc.). func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) { @@ -122,6 +124,8 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo { // Any client's internal or transport errors are returned as `error`, // see [apistatus] package for NeoFS-specific error types. // +// Context is required and must not be nil. It is used for network communication. +// // Exactly one return value is non-nil. Server status return is returned in ResNetworkInfo. // Reflects all internal errors in second return value (transport problems, response processing, etc.). func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) { diff --git a/client/object_hash.go b/client/object_hash.go index 734627b..847a801 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -157,6 +157,7 @@ func (x ResObjectHash) Checksums() [][]byte { // Return errors: // - [ErrMissingContainer] // - [ErrMissingObject] +// - [ErrMissingRanges] func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) { switch { case prm.addr.GetContainerID() == nil: diff --git a/user/util.go b/user/util.go index 3022ff9..c43d3ec 100644 --- a/user/util.go +++ b/user/util.go @@ -8,6 +8,7 @@ import ( neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto" ) +// ErrOwnerExtract is returned when failed to extract account info from key. var ErrOwnerExtract = errors.New("decode owner failed") // IDFromKey forms the ID using script hash calculated for the given key.