Documentation ¶
Index ¶
- Variables
- func ErrorFromV2(st *status.Status) error
- func ErrorToV2(err error) *status.Status
- func WriteInternalServerErr(x *ServerInternal, err error)
- type ContainerNotFound
- type EACLNotFound
- type LockNonRegularObject
- type NodeUnderMaintenance
- type ObjectAccessDenied
- type ObjectAlreadyRemoved
- type ObjectLocked
- type ObjectNotFound
- type ObjectOutOfRange
- type ServerInternal
- type SessionTokenExpired
- type SessionTokenNotFound
- type SignatureVerification
- type StatusV2
- type UnrecognizedStatusV2
- type WrongMagicNumber
Constants ¶
This section is empty.
Variables ¶
var ( // ErrServerInternal is an instance of ServerInternal error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrServerInternal ServerInternal // ErrWrongMagicNumber is an instance of WrongMagicNumber error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrWrongMagicNumber WrongMagicNumber // ErrSignatureVerification is an instance of SignatureVerification error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrSignatureVerification SignatureVerification // ErrNodeUnderMaintenance is an instance of NodeUnderMaintenance error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrNodeUnderMaintenance NodeUnderMaintenance )
var ( // ErrEACLNotFound is an instance of EACLNotFound error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrEACLNotFound EACLNotFound // ErrContainerNotFound is an instance of ContainerNotFound error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrContainerNotFound ContainerNotFound )
var ( // ErrObjectLocked is an instance of ObjectLocked error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrObjectLocked ObjectLocked // ErrObjectAlreadyRemoved is an instance of ObjectAlreadyRemoved error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrObjectAlreadyRemoved ObjectAlreadyRemoved // ErrLockNonRegularObject is an instance of LockNonRegularObject error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrLockNonRegularObject LockNonRegularObject // ErrObjectAccessDenied is an instance of ObjectAccessDenied error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrObjectAccessDenied ObjectAccessDenied // ErrObjectNotFound is an instance of ObjectNotFound error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrObjectNotFound ObjectNotFound // ErrObjectOutOfRange is an instance of ObjectOutOfRange error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrObjectOutOfRange ObjectOutOfRange )
var ( // ErrSessionTokenNotFound is an instance of SessionTokenNotFound error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrSessionTokenNotFound SessionTokenNotFound // ErrSessionTokenExpired is an instance of SessionTokenExpired error status. It's expected to be used for [errors.Is] // and MUST NOT be changed. ErrSessionTokenExpired SessionTokenExpired )
var Error = errors.New("api error")
Error describes common error which is a grouping type for any apistatus errors. Any apistatus error may be checked explicitly via it's type of just check the group via errors.Is(err, apistatus.Error).
Functions ¶
func ErrorFromV2 ¶
ErrorFromV2 converts status.Status message structure to error. Inverse to ErrorToV2 operation.
If result is not nil, it implements StatusV2. This fact should be taken into account only when passing the result to the inverse function ErrorToV2, casts are not compatibility-safe.
Below is the mapping of return codes to status instance types (with a description of parsing details). Note: notice if the return type is a pointer.
Successes:
- status.OK: nil (this also includes nil argument).
Common failures:
- status.Internal: *ServerInternal;
- status.SignatureVerificationFail: *SignatureVerification.
- status.WrongMagicNumber: *WrongMagicNumber.
- status.NodeUnderMaintenance: *NodeUnderMaintenance.
Object failures:
- object.StatusLocked: *ObjectLocked;
- object.StatusLockNonRegularObject: *LockNonRegularObject.
- object.StatusAccessDenied: *ObjectAccessDenied.
- object.StatusNotFound: *ObjectNotFound.
- object.StatusAlreadyRemoved: *ObjectAlreadyRemoved.
- object.StatusOutOfRange: *ObjectOutOfRange.
Container failures:
Session failures:
func ErrorToV2 ¶
ErrorToV2 converts error to status.Status message structure. Inverse to ErrorFromV2 operation.
If argument is the StatusV2 instance, it is converted directly. Otherwise, successes are converted with status.OK code w/o details and message, failures - with status.Internal and error text message w/o details.
func WriteInternalServerErr ¶
func WriteInternalServerErr(x *ServerInternal, err error)
WriteInternalServerErr writes err message to ServerInternal instance.
Types ¶
type ContainerNotFound ¶
type ContainerNotFound struct {
// contains filtered or unexported fields
}
ContainerNotFound describes status of the failure because of the missing container. Instances provide StatusV2 and error interfaces.
func (ContainerNotFound) Error ¶
func (x ContainerNotFound) Error() string
func (ContainerNotFound) ErrorToV2 ¶
func (x ContainerNotFound) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: CONTAINER_NOT_FOUND;
- string message: "container not found";
- details: empty.
type EACLNotFound ¶
type EACLNotFound struct {
// contains filtered or unexported fields
}
EACLNotFound describes status of the failure because of the missing eACL table. Instances provide StatusV2 and error interfaces.
func (EACLNotFound) Error ¶
func (x EACLNotFound) Error() string
func (EACLNotFound) ErrorToV2 ¶
func (x EACLNotFound) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: EACL_NOT_FOUND;
- string message: "eACL not found";
- details: empty.
type LockNonRegularObject ¶
type LockNonRegularObject struct {
// contains filtered or unexported fields
}
LockNonRegularObject describes status returned on locking the non-regular object. Instances provide StatusV2 and error interfaces.
func (LockNonRegularObject) Error ¶
func (x LockNonRegularObject) Error() string
func (LockNonRegularObject) ErrorToV2 ¶
func (x LockNonRegularObject) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: LOCK_NON_REGULAR_OBJECT;
- string message: "locking non-regular object is forbidden";
- details: empty.
type NodeUnderMaintenance ¶
type NodeUnderMaintenance struct {
// contains filtered or unexported fields
}
NodeUnderMaintenance describes failure status for nodes being under maintenance. Instances provide StatusV2 and error interfaces.
func (NodeUnderMaintenance) Error ¶
func (x NodeUnderMaintenance) Error() string
Error implements the error interface.
func (NodeUnderMaintenance) ErrorToV2 ¶
func (x NodeUnderMaintenance) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: NODE_UNDER_MAINTENANCE;
- string message: written message via NodeUnderMaintenance.SetMessage or "node is under maintenance" as a default message;
- details: empty.
func (NodeUnderMaintenance) Is ¶
func (x NodeUnderMaintenance) Is(target error) bool
Is implements interface for correct checking current error type with errors.Is.
func (NodeUnderMaintenance) Message ¶
func (x NodeUnderMaintenance) Message() string
Message returns status message. Zero status returns empty message. Message should be used for debug purposes only.
See also SetMessage.
func (*NodeUnderMaintenance) SetMessage ¶
func (x *NodeUnderMaintenance) SetMessage(v string)
SetMessage writes signature verification failure message. Message should be used for debug purposes only.
See also Message.
type ObjectAccessDenied ¶
type ObjectAccessDenied struct {
// contains filtered or unexported fields
}
ObjectAccessDenied describes status of the failure because of the access control violation. Instances provide StatusV2 and error interfaces.
func (ObjectAccessDenied) Error ¶
func (x ObjectAccessDenied) Error() string
func (ObjectAccessDenied) ErrorToV2 ¶
func (x ObjectAccessDenied) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: ACCESS_DENIED;
- string message: "access to object operation denied";
- details: empty.
func (ObjectAccessDenied) Is ¶
func (x ObjectAccessDenied) Is(target error) bool
Is implements interface for correct checking current error type with errors.Is.
func (ObjectAccessDenied) Reason ¶
func (x ObjectAccessDenied) Reason() string
Reason returns human-readable access rejection reason returned by the server. Returns empty value is reason is not presented.
func (*ObjectAccessDenied) WriteReason ¶
func (x *ObjectAccessDenied) WriteReason(reason string)
WriteReason writes human-readable access rejection reason.
type ObjectAlreadyRemoved ¶
type ObjectAlreadyRemoved struct {
// contains filtered or unexported fields
}
ObjectAlreadyRemoved describes status of the failure because object has been already removed. Instances provide Status and StatusV2 interfaces.
func (ObjectAlreadyRemoved) Error ¶
func (x ObjectAlreadyRemoved) Error() string
func (ObjectAlreadyRemoved) ErrorToV2 ¶
func (x ObjectAlreadyRemoved) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: OBJECT_ALREADY_REMOVED;
- string message: "object already removed";
- details: empty.
type ObjectLocked ¶
type ObjectLocked struct {
// contains filtered or unexported fields
}
ObjectLocked describes status of the failure because of the locked object. Instances provide StatusV2 and error interfaces.
func (ObjectLocked) Error ¶
func (x ObjectLocked) Error() string
func (ObjectLocked) ErrorToV2 ¶
func (x ObjectLocked) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: LOCKED;
- string message: "object is locked";
- details: empty.
type ObjectNotFound ¶
type ObjectNotFound struct {
// contains filtered or unexported fields
}
ObjectNotFound describes status of the failure because of the missing object. Instances provide StatusV2 and error interfaces.
func (ObjectNotFound) Error ¶
func (x ObjectNotFound) Error() string
func (ObjectNotFound) ErrorToV2 ¶
func (x ObjectNotFound) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: OBJECT_NOT_FOUND;
- string message: "object not found";
- details: empty.
type ObjectOutOfRange ¶
type ObjectOutOfRange struct {
// contains filtered or unexported fields
}
ObjectOutOfRange describes status of the failure because of the incorrect provided object ranges. Instances provide StatusV2 and error interfaces.
func (ObjectOutOfRange) Error ¶
func (x ObjectOutOfRange) Error() string
func (ObjectOutOfRange) ErrorToV2 ¶
func (x ObjectOutOfRange) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: OUT_OF_RANGE;
- string message: "out of range";
- details: empty.
type ServerInternal ¶
type ServerInternal struct {
// contains filtered or unexported fields
}
ServerInternal describes failure statuses related to internal server errors. Instances provide StatusV2 and error interfaces.
The status is purely informative, the client should not go into details of the error except for debugging needs.
func (ServerInternal) Error ¶
func (x ServerInternal) Error() string
func (ServerInternal) ErrorToV2 ¶
func (x ServerInternal) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: INTERNAL;
- string message: empty;
- details: empty.
func (ServerInternal) Is ¶
func (x ServerInternal) Is(target error) bool
Is implements interface for correct checking current error type with errors.Is.
func (ServerInternal) Message ¶
func (x ServerInternal) Message() string
Message returns message describing internal server error.
Message should be used for debug purposes only. By default, it is empty.
func (*ServerInternal) SetMessage ¶
func (x *ServerInternal) SetMessage(msg string)
SetMessage sets message describing internal error.
Message should be used for debug purposes only.
type SessionTokenExpired ¶
type SessionTokenExpired struct {
// contains filtered or unexported fields
}
SessionTokenExpired describes status of the failure because of the expired session token. Instances provide StatusV2 and error interfaces.
func (SessionTokenExpired) Error ¶
func (x SessionTokenExpired) Error() string
func (SessionTokenExpired) ErrorToV2 ¶
func (x SessionTokenExpired) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: TOKEN_EXPIRED;
- string message: "expired session token";
- details: empty.
type SessionTokenNotFound ¶
type SessionTokenNotFound struct {
// contains filtered or unexported fields
}
SessionTokenNotFound describes status of the failure because of the missing session token. Instances provide StatusV2 and error interfaces.
func (SessionTokenNotFound) Error ¶
func (x SessionTokenNotFound) Error() string
func (SessionTokenNotFound) ErrorToV2 ¶
func (x SessionTokenNotFound) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: TOKEN_NOT_FOUND;
- string message: "session token not found";
- details: empty.
type SignatureVerification ¶
type SignatureVerification struct {
// contains filtered or unexported fields
}
SignatureVerification describes failure status related to signature verification. Instances provide StatusV2 and error interfaces.
func (SignatureVerification) Error ¶
func (x SignatureVerification) Error() string
func (SignatureVerification) ErrorToV2 ¶
func (x SignatureVerification) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: SIGNATURE_VERIFICATION_FAIL;
- string message: written message via SignatureVerification.SetMessage or "signature verification failed" as a default message;
- details: empty.
func (SignatureVerification) Is ¶
func (x SignatureVerification) Is(target error) bool
Is implements interface for correct checking current error type with errors.Is.
func (SignatureVerification) Message ¶
func (x SignatureVerification) Message() string
Message returns status message. Zero status returns empty message. Message should be used for debug purposes only.
See also SetMessage.
func (*SignatureVerification) SetMessage ¶
func (x *SignatureVerification) SetMessage(v string)
SetMessage writes signature verification failure message. Message should be used for debug purposes only.
See also Message.
type StatusV2 ¶
type StatusV2 interface { // ErrorToV2 returns the status as github.com/epicchainlabs/epicchain-api-go/v2/status.Status message structure. ErrorToV2() *status.Status }
StatusV2 defines a variety of status instances compatible with NeoFS API V2 protocol.
Note: it is not recommended to use this type directly, it is intended for documentation of the library functionality.
type UnrecognizedStatusV2 ¶
type UnrecognizedStatusV2 struct {
// contains filtered or unexported fields
}
UnrecognizedStatusV2 describes status of the uncertain failure. Instances provide StatusV2 and error interfaces.
var ErrUnrecognizedStatusV2 UnrecognizedStatusV2
ErrUnrecognizedStatusV2 is an instance of UnrecognizedStatusV2 error status. It's expected to be used for errors.Is and MUST NOT be changed.
func (UnrecognizedStatusV2) Error ¶
func (x UnrecognizedStatusV2) Error() string
type WrongMagicNumber ¶
type WrongMagicNumber struct {
// contains filtered or unexported fields
}
WrongMagicNumber describes failure status related to incorrect network magic. Instances provide StatusV2 and error interfaces.
func (WrongMagicNumber) CorrectMagic ¶
func (x WrongMagicNumber) CorrectMagic() (magic uint64, ok int8)
CorrectMagic returns network magic returned by the server. Second value indicates presence status:
- -1 if number is presented in incorrect format
- 0 if number is not presented
- +1 otherwise
func (WrongMagicNumber) Error ¶
func (x WrongMagicNumber) Error() string
func (WrongMagicNumber) ErrorToV2 ¶
func (x WrongMagicNumber) ErrorToV2() *status.Status
ErrorToV2 implements StatusV2 interface method. If the value was returned by ErrorFromV2, returns the source message. Otherwise, returns message with
- code: WRONG_MAGIC_NUMBER;
- string message: empty;
- details: empty.
func (WrongMagicNumber) Is ¶
func (x WrongMagicNumber) Is(target error) bool
Is implements interface for correct checking current error type with errors.Is.
func (*WrongMagicNumber) WriteCorrectMagic ¶
func (x *WrongMagicNumber) WriteCorrectMagic(magic uint64)
WriteCorrectMagic writes correct network magic.