Documentation
¶
Overview ¶
Package apierror holds the errors a substrate server deliberately returns to its caller.
An apierror is not a gRPC status: it has no GRPCStatus method, so a status received from an upstream service never decides the code a server returns, however it is wrapped. To propagate an upstream code, check it at the call site and construct the apierror that says what it means to this server's caller. Anything that is neither an apierror nor a context error reaches the caller as codes.Internal.
There is one constructor per code a server chooses. OK and Unknown have none, and neither do Canceled and DeadlineExceeded: return or wrap the context's error instead, and Code and FromError map it.
Index ¶
- func Aborted(format string, args ...any) error
- func AlreadyExists(format string, args ...any) error
- func Code(err error) codes.Code
- func DataLoss(format string, args ...any) error
- func FailedPrecondition(format string, args ...any) error
- func FromError(err error) (s *status.Status, ok bool)
- func Internal(format string, args ...any) error
- func InvalidArgument(format string, args ...any) error
- func NotFound(format string, args ...any) error
- func PermissionDenied(format string, args ...any) error
- func ResourceExhausted(format string, args ...any) error
- func Unauthenticated(format string, args ...any) error
- func Unavailable(format string, args ...any) error
- func Unimplemented(format string, args ...any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aborted ¶
Aborted reports a request that lost a concurrency conflict, such as a version mismatch. Retrying from a fresh read can succeed.
func AlreadyExists ¶
AlreadyExists reports that a resource the request creates already exists.
func Code ¶
Code returns the code err reaches the caller with, the same as FromError(err).Code(): codes.OK for nil, and codes.Internal for an error that is neither an apierror nor a context error. It never reads a gRPC status.
func FailedPrecondition ¶
FailedPrecondition reports that the system is not in the state the request requires. Retrying is pointless until that state changes.
func FromError ¶
FromError converts err to the status a server returns for it. The message is the apierror's own, without the context added by errors wrapping it. ok is false when err is neither an apierror nor a context error; the status is then codes.Internal with err's text, which the caller may reword.
func Internal ¶
Internal reports a server-side failure with a message chosen for the caller. A plain error also reaches the caller as codes.Internal, but with whatever text it carries.
func InvalidArgument ¶
InvalidArgument reports a request that is malformed regardless of the system's state.
func PermissionDenied ¶
PermissionDenied reports an authenticated caller that may not perform the request.
func ResourceExhausted ¶
ResourceExhausted reports that a quota or capacity limit refused the request.
func Unauthenticated ¶
Unauthenticated reports a caller whose identity could not be established.
func Unavailable ¶
Unavailable reports that the request was not acted on, so retrying it, here or elsewhere, is safe. Never use it for a failure partway through.
func Unimplemented ¶
Unimplemented reports a request this server does not support.
Types ¶
This section is empty.