status
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package status implements errors returned by gRPC. These errors areserialized and transmitted on the wire between server and client, and allowfor additional data to be transmitted via the Details field in the statusproto. gRPC service handlers should return an error created by thispackage, and gRPC clients should expect a corresponding error to bereturned from the RPC call.
This package upholds the invariants that a non-nil error may notcontain an OK code, and an OK code must result in a nil error.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcCode¶added inv1.9.0
Code returns the Code of the error if it is a Status error or if it wraps aStatus error. If that is not the case, it returns codes.OK if err is nil, orcodes.Unknown otherwise.
funcErrorProto¶
ErrorProto returns an error representing s. If s.Code is OK, returns nil.
Types¶
typeStatus¶
Status references google.golang.org/grpc/internal/status. It represents anRPC status code, message, and details. It is immutable and should becreated with New, Newf, or FromProto.https://godoc.org/google.golang.org/grpc/internal/status
funcConvert¶added inv1.10.0
Convert is a convenience function which removes the need to handle theboolean return value from FromError.
funcFromContextError¶added inv1.13.0
FromContextError converts a context error or wrapped context error into aStatus. It returns a Status with codes.OK if err is nil, or a Status withcodes.Unknown if err is non-nil and not a context error.
funcFromError¶
FromError returns a Status representation of err.
If err was produced by this package or implements the method `GRPCStatus()*Status` and `GRPCStatus()` does not return nil, or if err wraps a typesatisfying this, the Status from `GRPCStatus()` is returned. For wrappederrors, the message returned contains the entire err.Error() text and notjust the wrapped status. In that case, ok is true.
If err is nil, a Status is returned with codes.OK and no message, and okis true.
If err implements the method `GRPCStatus() *Status` and `GRPCStatus()`returns nil (which maps to Codes.OK), or if err wraps a typesatisfying this, a Status is returned with codes.Unknown and err'sError() message, and ok is false.
Otherwise, err is an error not compatible with this package. In thiscase, a Status is returned with codes.Unknown and err's Error() message,and ok is false.