Documentation
¶
Overview ¶
Package errors is a robust and easy-to-use error package. It supports verbosity levels, maintains causal errors, implements stack tracing, maps to common HTTP error codes, exposes temporary and timeout errors, implements JSON marshalling, and is GRPC compatible.
Index ¶
- Constants
- func NewPassthroughError(msg string, err error) error
- func SetVerbosity(v int)
- type AbortedError
- func (e *AbortedError) Error() string
- func (e *AbortedError) GRPCStatus() *status.Status
- func (e *AbortedError) GetCause() error
- func (e *AbortedError) GetCode() int
- func (e *AbortedError) GetMessage() string
- func (e *AbortedError) GetStack() stack
- func (e *AbortedError) Temporary() bool
- func (e *AbortedError) Timeout() bool
- type AlreadyExistsError
- func (e *AlreadyExistsError) Error() string
- func (e *AlreadyExistsError) GRPCStatus() *status.Status
- func (e *AlreadyExistsError) GetCause() error
- func (e *AlreadyExistsError) GetCode() int
- func (e *AlreadyExistsError) GetMessage() string
- func (e *AlreadyExistsError) GetStack() stack
- func (e *AlreadyExistsError) Temporary() bool
- func (e *AlreadyExistsError) Timeout() bool
- type CanceledError
- func (e *CanceledError) Error() string
- func (e *CanceledError) GRPCStatus() *status.Status
- func (e *CanceledError) GetCause() error
- func (e *CanceledError) GetCode() int
- func (e *CanceledError) GetMessage() string
- func (e *CanceledError) GetStack() stack
- func (e *CanceledError) Temporary() bool
- func (e *CanceledError) Timeout() bool
- type DataLossError
- func (e *DataLossError) Error() string
- func (e *DataLossError) GRPCStatus() *status.Status
- func (e *DataLossError) GetCause() error
- func (e *DataLossError) GetCode() int
- func (e *DataLossError) GetMessage() string
- func (e *DataLossError) GetStack() stack
- func (e *DataLossError) Temporary() bool
- func (e *DataLossError) Timeout() bool
- type DeadlineExceededError
- func (e *DeadlineExceededError) Error() string
- func (e *DeadlineExceededError) GRPCStatus() *status.Status
- func (e *DeadlineExceededError) GetCause() error
- func (e *DeadlineExceededError) GetCode() int
- func (e *DeadlineExceededError) GetMessage() string
- func (e *DeadlineExceededError) GetStack() stack
- func (e *DeadlineExceededError) Temporary() bool
- func (e *DeadlineExceededError) Timeout() bool
- type Errors
- func (e *Errors) Append(errs ...error)
- func (e Errors) Error() string
- func (e *Errors) GRPCStatus() *status.Status
- func (e *Errors) GetCause() error
- func (e *Errors) GetCode() int
- func (e *Errors) GetMessage() string
- func (e *Errors) GetStack() stack
- func (e *Errors) Len() int
- func (e *Errors) Merge(in *Errors)
- func (e *Errors) Pop() error
- func (e *Errors) Shift() error
- func (e *Errors) Temporary() bool
- func (e *Errors) Timeout() bool
- type FailedPreconditionError
- func (e *FailedPreconditionError) Error() string
- func (e *FailedPreconditionError) GRPCStatus() *status.Status
- func (e *FailedPreconditionError) GetCause() error
- func (e *FailedPreconditionError) GetCode() int
- func (e *FailedPreconditionError) GetMessage() string
- func (e *FailedPreconditionError) GetStack() stack
- func (e *FailedPreconditionError) Temporary() bool
- func (e *FailedPreconditionError) Timeout() bool
- type InternalError
- func (e *InternalError) Error() string
- func (e *InternalError) GRPCStatus() *status.Status
- func (e *InternalError) GetCause() error
- func (e *InternalError) GetCode() int
- func (e *InternalError) GetMessage() string
- func (e *InternalError) GetStack() stack
- func (e *InternalError) Temporary() bool
- func (e *InternalError) Timeout() bool
- type InvalidArgumentError
- func (e *InvalidArgumentError) Error() string
- func (e *InvalidArgumentError) GRPCStatus() *status.Status
- func (e *InvalidArgumentError) GetCause() error
- func (e *InvalidArgumentError) GetCode() int
- func (e *InvalidArgumentError) GetMessage() string
- func (e *InvalidArgumentError) GetStack() stack
- func (e *InvalidArgumentError) Temporary() bool
- func (e *InvalidArgumentError) Timeout() bool
- type NotFoundError
- func (e *NotFoundError) Error() string
- func (e *NotFoundError) GRPCStatus() *status.Status
- func (e *NotFoundError) GetCause() error
- func (e *NotFoundError) GetCode() int
- func (e *NotFoundError) GetMessage() string
- func (e *NotFoundError) GetStack() stack
- func (e *NotFoundError) Temporary() bool
- func (e *NotFoundError) Timeout() bool
- type NotImplementedError
- func (e *NotImplementedError) Error() string
- func (e *NotImplementedError) GRPCStatus() *status.Status
- func (e *NotImplementedError) GetCause() error
- func (e *NotImplementedError) GetCode() int
- func (e *NotImplementedError) GetMessage() string
- func (e *NotImplementedError) GetStack() stack
- func (e *NotImplementedError) Temporary() bool
- func (e *NotImplementedError) Timeout() bool
- type OutOfRangeError
- func (e *OutOfRangeError) Error() string
- func (e *OutOfRangeError) GRPCStatus() *status.Status
- func (e *OutOfRangeError) GetCause() error
- func (e *OutOfRangeError) GetCode() int
- func (e *OutOfRangeError) GetMessage() string
- func (e *OutOfRangeError) GetStack() stack
- func (e *OutOfRangeError) Temporary() bool
- func (e *OutOfRangeError) Timeout() bool
- type PermissionDeniedError
- func (e *PermissionDeniedError) Error() string
- func (e *PermissionDeniedError) GRPCStatus() *status.Status
- func (e *PermissionDeniedError) GetCause() error
- func (e *PermissionDeniedError) GetCode() int
- func (e *PermissionDeniedError) GetMessage() string
- func (e *PermissionDeniedError) GetStack() stack
- func (e *PermissionDeniedError) Temporary() bool
- func (e *PermissionDeniedError) Timeout() bool
- type ResourceExhaustedError
- func (e *ResourceExhaustedError) Error() string
- func (e *ResourceExhaustedError) GRPCStatus() *status.Status
- func (e *ResourceExhaustedError) GetCause() error
- func (e *ResourceExhaustedError) GetCode() int
- func (e *ResourceExhaustedError) GetMessage() string
- func (e *ResourceExhaustedError) GetStack() stack
- func (e *ResourceExhaustedError) Temporary() bool
- func (e *ResourceExhaustedError) Timeout() bool
- type UnauthenticatedError
- func (e *UnauthenticatedError) Error() string
- func (e *UnauthenticatedError) GRPCStatus() *status.Status
- func (e *UnauthenticatedError) GetCause() error
- func (e *UnauthenticatedError) GetCode() int
- func (e *UnauthenticatedError) GetMessage() string
- func (e *UnauthenticatedError) GetStack() stack
- func (e *UnauthenticatedError) Temporary() bool
- func (e *UnauthenticatedError) Timeout() bool
- type UnavailableError
- func (e *UnavailableError) Error() string
- func (e *UnavailableError) GRPCStatus() *status.Status
- func (e *UnavailableError) GetCause() error
- func (e *UnavailableError) GetCode() int
- func (e *UnavailableError) GetMessage() string
- func (e *UnavailableError) GetStack() stack
- func (e *UnavailableError) Temporary() bool
- func (e *UnavailableError) Timeout() bool
- type UnknownError
- func (e *UnknownError) Error() string
- func (e *UnknownError) GRPCStatus() *status.Status
- func (e *UnknownError) GetCause() error
- func (e *UnknownError) GetCode() int
- func (e *UnknownError) GetMessage() string
- func (e *UnknownError) GetStack() stack
- func (e *UnknownError) Temporary() bool
- func (e *UnknownError) Timeout() bool
Constants ¶
const ( Info = iota Verbose Debug Trace )
Constants for use with SetVerbosity(...)
Variables ¶
This section is empty.
Functions ¶
func NewPassthroughError ¶
NewPassthroughError handles an error from an external dependency. If the error is a timeout, canceled, unavailable, unknown, or temporary error, it is passed through as the appropriate correlating type from this package. Otherwise, an internal error with the provided message is returned.
Types ¶
type AbortedError ¶
type AbortedError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
AbortedError indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.
A litmus test that may help a service implementor in deciding between ResourceExhaustedError, UnavailableError, and AbortedError:
(a) Use ResourceExhaustedError for client errors like exceeding allowed rate limits. The client may retry the failing call after they have resolved the causal issue. (b) Use UnavailableError for server errors like inability to accomodate current load or planned server maintenance. The client may retry the failing call. (c) Use AbortedError if the client should retry at a higher-level (e.g., restarting a read-modify-write sequence).
Example error Message:
ABORTED. Couldn’t acquire lock on resource ‘xxx’.
HTTP Mapping: 409 CONFLICT
RPC Mapping: ABORTED
func NewAbortedError ¶
func NewAbortedError(Message string, cause ...error) *AbortedError
NewAbortedError returns a new AbortedError.
func (*AbortedError) Error ¶
func (e *AbortedError) Error() string
Error implements the error interface
func (*AbortedError) GRPCStatus ¶
func (e *AbortedError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*AbortedError) GetCause ¶
func (e *AbortedError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*AbortedError) GetCode ¶
func (e *AbortedError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*AbortedError) GetMessage ¶
func (e *AbortedError) GetMessage() string
GetMessage returns the message associated with this error.
func (*AbortedError) GetStack ¶
func (e *AbortedError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*AbortedError) Temporary ¶
func (e *AbortedError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*AbortedError) Timeout ¶
func (e *AbortedError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type AlreadyExistsError ¶
type AlreadyExistsError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
AlreadyExistsError means an attempt to create an entity failed because one already exists.
Example error Message:
ALREADY EXISTS. Resource 'xxx' already exists.
HTTP Mapping: 409 CONFLICT
RPC Mapping: ALREADY_EXISTS
func NewAlreadyExistsError ¶
func NewAlreadyExistsError(Message string, cause ...error) *AlreadyExistsError
NewAlreadyExistsError returns a new AlreadyExistsError.
func (*AlreadyExistsError) Error ¶
func (e *AlreadyExistsError) Error() string
Error implements the error interface
func (*AlreadyExistsError) GRPCStatus ¶
func (e *AlreadyExistsError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*AlreadyExistsError) GetCause ¶
func (e *AlreadyExistsError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*AlreadyExistsError) GetCode ¶
func (e *AlreadyExistsError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*AlreadyExistsError) GetMessage ¶
func (e *AlreadyExistsError) GetMessage() string
GetMessage returns the message associated with this error.
func (*AlreadyExistsError) GetStack ¶
func (e *AlreadyExistsError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*AlreadyExistsError) Temporary ¶
func (e *AlreadyExistsError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*AlreadyExistsError) Timeout ¶
func (e *AlreadyExistsError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type CanceledError ¶
type CanceledError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
CanceledError indicates the operation was canceled (typically by the caller).
Example error Message:
CANCELED.
HTTP Mapping: 499 CLIENT CLOSED REQUEST
RPC Mapping: CANCELED
func NewCanceledError ¶
func NewCanceledError(Message string, cause ...error) *CanceledError
NewCanceledError returns a new CanceledError.
func (*CanceledError) Error ¶
func (e *CanceledError) Error() string
Error implements the error interface
func (*CanceledError) GRPCStatus ¶
func (e *CanceledError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*CanceledError) GetCause ¶
func (e *CanceledError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*CanceledError) GetCode ¶
func (e *CanceledError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*CanceledError) GetMessage ¶
func (e *CanceledError) GetMessage() string
GetMessage returns the message associated with this error.
func (*CanceledError) GetStack ¶
func (e *CanceledError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*CanceledError) Temporary ¶
func (e *CanceledError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*CanceledError) Timeout ¶
func (e *CanceledError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type DataLossError ¶
type DataLossError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
DataLossError indicates unrecoverable data loss or corruption.
Since the client cannot fix this server error, it is not useful to generate additional error details. To avoid leaking sensitive information under error conditions, only a generic error Message is marshalled to JSON or returned via GRPC status.
Error Message:
DATA LOSS. Unrecoverable data loss or data corruption.
HTTP Mapping: 500 INTERNAL SERVER ERROR
RPC Mapping: DATA_LOSS
func NewDataLossError ¶
func NewDataLossError(Message string, cause ...error) *DataLossError
NewDataLossError returns a new DataLossError.
func (*DataLossError) Error ¶
func (e *DataLossError) Error() string
Error implements the error interface
func (*DataLossError) GRPCStatus ¶
func (e *DataLossError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*DataLossError) GetCause ¶
func (e *DataLossError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*DataLossError) GetCode ¶
func (e *DataLossError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*DataLossError) GetMessage ¶
func (e *DataLossError) GetMessage() string
GetMessage returns the message associated with this error.
func (*DataLossError) GetStack ¶
func (e *DataLossError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*DataLossError) Temporary ¶
func (e *DataLossError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*DataLossError) Timeout ¶
func (e *DataLossError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type DeadlineExceededError ¶
type DeadlineExceededError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
DeadlineExceededError means operation expired before completion. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire.
Since the client cannot fix this server error, it is not useful to generate additional error details. To avoid leaking sensitive information under error conditions, only a generic error Message is marshalled to JSON or returned via GRPC status.
Error Message:
DEADLINE EXCEEDED. Server timeout.
HTTP Mapping: 504 GATEWAY TIMEOUT
RPC Mapping: DEADLINE_EXCEEDED
func NewDeadlineExceededError ¶
func NewDeadlineExceededError(Message string, cause ...error) *DeadlineExceededError
NewDeadlineExceededError returns a new DeadlineExceededError.
func (*DeadlineExceededError) Error ¶
func (e *DeadlineExceededError) Error() string
Error implements the error interface
func (*DeadlineExceededError) GRPCStatus ¶
func (e *DeadlineExceededError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*DeadlineExceededError) GetCause ¶
func (e *DeadlineExceededError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*DeadlineExceededError) GetCode ¶
func (e *DeadlineExceededError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*DeadlineExceededError) GetMessage ¶
func (e *DeadlineExceededError) GetMessage() string
GetMessage returns the message associated with this error.
func (*DeadlineExceededError) GetStack ¶
func (e *DeadlineExceededError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*DeadlineExceededError) Temporary ¶
func (e *DeadlineExceededError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*DeadlineExceededError) Timeout ¶
func (e *DeadlineExceededError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type Errors ¶
Errors is a container for multiple errors and implements the error interface
func (*Errors) GRPCStatus ¶
GRPCStatus implements an interface required to return proper GRPC status codes
func (*Errors) GetMessage ¶
GetMessage returns the message associated with this error.
func (*Errors) GetStack ¶
func (e *Errors) GetStack() stack
GetStack returns the trace stack associated with this error.
type FailedPreconditionError ¶
type FailedPreconditionError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
FailedPreconditionError indicates operation was rejected because the system is not in a state required for the operation's execution. For example, directory to be deleted may be non-empty, an rmdir operation is applied to a non-directory, etc.
Service implementors can use the following guidelines to decide between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: (a) Use UNAVAILABLE if the client can retry just the failing call. (b) Use ABORTED if the client should retry at a higher level (e.g., when a client-specified test-and-set fails, indicating the client should restart a read-modify-write sequence). (c) Use FAILED_PRECONDITION if the client should not retry until the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless the files are deleted from the directory.
Example error Message:
FAILED PRECONDITION. Resource xxx is a non-empty directory, so it cannot be deleted.
HTTP Mapping: 400 BAD REQUEST
RPC Mapping: FAILED_PRECONDITION
func NewFailedPreconditionError ¶
func NewFailedPreconditionError(Message string, cause ...error) *FailedPreconditionError
NewFailedPreconditionError returns a new FailedPreconditionError.
func (*FailedPreconditionError) Error ¶
func (e *FailedPreconditionError) Error() string
Error implements the error interface
func (*FailedPreconditionError) GRPCStatus ¶
func (e *FailedPreconditionError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*FailedPreconditionError) GetCause ¶
func (e *FailedPreconditionError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*FailedPreconditionError) GetCode ¶
func (e *FailedPreconditionError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*FailedPreconditionError) GetMessage ¶
func (e *FailedPreconditionError) GetMessage() string
GetMessage returns the message associated with this error.
func (*FailedPreconditionError) GetStack ¶
func (e *FailedPreconditionError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*FailedPreconditionError) Temporary ¶
func (e *FailedPreconditionError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*FailedPreconditionError) Timeout ¶
func (e *FailedPreconditionError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type InternalError ¶
type InternalError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
InternalError means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken.
A litmus test that may help a service implementor in deciding between UnknownError and InternalError:
(a) Use UnknownError for generic server-side errors that may be recoverable (UnknownError.Temporary() will return true). (b) Use InternalError for generic server-side errors that are not recoverable (InternalError.Temporary() will return false).
Since the client cannot fix this server error, it is not useful to generate additional error details. To avoid leaking sensitive information under error conditions, only a generic error Message is marshalled to JSON or returned via GRPC status.
Error Message:
INTERNAL ERROR.
HTTP Mapping: 500 INTERNAL SERVER ERROR
RPC Mapping: INTERNAL
func NewInternalError ¶
func NewInternalError(Message string, cause ...error) *InternalError
NewInternalError returns a new InternalError.
func (*InternalError) Error ¶
func (e *InternalError) Error() string
Error implements the error interface
func (*InternalError) GRPCStatus ¶
func (e *InternalError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*InternalError) GetCause ¶
func (e *InternalError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*InternalError) GetCode ¶
func (e *InternalError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*InternalError) GetMessage ¶
func (e *InternalError) GetMessage() string
GetMessage returns the message associated with this error.
func (*InternalError) GetStack ¶
func (e *InternalError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*InternalError) Temporary ¶
func (e *InternalError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*InternalError) Timeout ¶
func (e *InternalError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type InvalidArgumentError ¶
type InvalidArgumentError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
InvalidArgumentError indicates client specified an invalid argument. Note that this differs from FailedPreconditionError. It indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name).
Example error Message:
INVALID ARGUMENT. Request field x.y.z is xxx, expected one of [yyy, zzz].
HTTP Mapping: 400 BAD REQUEST
RPC Mapping: INVALID_ARGUMENT
func NewInvalidArgumentError ¶
func NewInvalidArgumentError(Message string, cause ...error) *InvalidArgumentError
NewInvalidArgumentError returns a new InvalidArgumentError.
func (*InvalidArgumentError) Error ¶
func (e *InvalidArgumentError) Error() string
Error implements the error interface
func (*InvalidArgumentError) GRPCStatus ¶
func (e *InvalidArgumentError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*InvalidArgumentError) GetCause ¶
func (e *InvalidArgumentError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*InvalidArgumentError) GetCode ¶
func (e *InvalidArgumentError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*InvalidArgumentError) GetMessage ¶
func (e *InvalidArgumentError) GetMessage() string
GetMessage returns the message associated with this error.
func (*InvalidArgumentError) GetStack ¶
func (e *InvalidArgumentError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*InvalidArgumentError) Temporary ¶
func (e *InvalidArgumentError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*InvalidArgumentError) Timeout ¶
func (e *InvalidArgumentError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type NotFoundError ¶
type NotFoundError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
NotFoundError means some requested entity (e.g., file or directory) was not found.
Example error Message:
NOT FOUND. Resource 'xxx' not found.
HTTP Mapping: 404 NOT FOUND
RPC Mapping: NOT_FOUND
func NewNotFoundError ¶
func NewNotFoundError(Message string, cause ...error) *NotFoundError
NewNotFoundError returns a new NotFoundError.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
Error implements the error interface
func (*NotFoundError) GRPCStatus ¶
func (e *NotFoundError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*NotFoundError) GetCause ¶
func (e *NotFoundError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*NotFoundError) GetCode ¶
func (e *NotFoundError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*NotFoundError) GetMessage ¶
func (e *NotFoundError) GetMessage() string
GetMessage returns the message associated with this error.
func (*NotFoundError) GetStack ¶
func (e *NotFoundError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*NotFoundError) Temporary ¶
func (e *NotFoundError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*NotFoundError) Timeout ¶
func (e *NotFoundError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type NotImplementedError ¶
type NotImplementedError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
NotImplementedError indicates operation is not implemented or not supported/enabled in this service.
Example error Message:
NOT IMPLEMENTED. Method 'xxx' not implemented.
HTTP Mapping: 501 NOT IMPLEMENTED
RPC Mapping: NOT_IMPLEMENTED
func NewNotImplementedError ¶
func NewNotImplementedError(Message string, cause ...error) *NotImplementedError
NewNotImplementedError returns a new NotImplementedError.
func (*NotImplementedError) Error ¶
func (e *NotImplementedError) Error() string
Error implements the error interface
func (*NotImplementedError) GRPCStatus ¶
func (e *NotImplementedError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*NotImplementedError) GetCause ¶
func (e *NotImplementedError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*NotImplementedError) GetCode ¶
func (e *NotImplementedError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*NotImplementedError) GetMessage ¶
func (e *NotImplementedError) GetMessage() string
GetMessage returns the message associated with this error.
func (*NotImplementedError) GetStack ¶
func (e *NotImplementedError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*NotImplementedError) Temporary ¶
func (e *NotImplementedError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*NotImplementedError) Timeout ¶
func (e *NotImplementedError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type OutOfRangeError ¶
type OutOfRangeError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
OutOfRangeError means operation was attempted past the valid range. E.g., seeking or reading past end of file.
Unlike InvalidArgumentError, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate InvalidArgument if asked to read at an offset that is not in the range [0,2^32-1], but it will generate OutOfRangeError if asked to read from an offset past the current file size.
There is a fair bit of overlap between FailedPreconditionError and OutOfRangeError. We recommend using OutOfRangeError (the more specific error) when it applies so that callers who are iterating through a space can easily look for an OutOfRangeError to detect when they are done.
Example error Message:
OUT OF RANGE. Parameter 'age' is out of range [0, 125].
HTTP Mapping: 400 BAD REQUEST
RPC Mapping: OUT_OF_RANGE
func NewOutOfRangeError ¶
func NewOutOfRangeError(Message string, cause ...error) *OutOfRangeError
NewOutOfRangeError returns a new OutOfRangeError.
func (*OutOfRangeError) Error ¶
func (e *OutOfRangeError) Error() string
Error implements the error interface
func (*OutOfRangeError) GRPCStatus ¶
func (e *OutOfRangeError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*OutOfRangeError) GetCause ¶
func (e *OutOfRangeError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*OutOfRangeError) GetCode ¶
func (e *OutOfRangeError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*OutOfRangeError) GetMessage ¶
func (e *OutOfRangeError) GetMessage() string
GetMessage returns the message associated with this error.
func (*OutOfRangeError) GetStack ¶
func (e *OutOfRangeError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*OutOfRangeError) Temporary ¶
func (e *OutOfRangeError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*OutOfRangeError) Timeout ¶
func (e *OutOfRangeError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type PermissionDeniedError ¶
type PermissionDeniedError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
PermissionDeniedError indicates the caller does not have permission to execute the specified operation. It must not be used for rejections caused by exhausting some resource (use ResourceExhaustedError instead for those errors). It must not be used if the caller cannot be identified (use UnauthenticatedError instead for those errors).
Example error Message:
PERMISSION DENIED. Permission 'xxx' denied on file 'yyy'.
HTTP Mapping: 403 FORBIDDEN
RPC Mapping: PERMISSION_DENIED
func NewPermissionDeniedError ¶
func NewPermissionDeniedError(Message string, cause ...error) *PermissionDeniedError
NewPermissionDeniedError returns a new PermissionDeniedError.
func (*PermissionDeniedError) Error ¶
func (e *PermissionDeniedError) Error() string
Error implements the error interface
func (*PermissionDeniedError) GRPCStatus ¶
func (e *PermissionDeniedError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*PermissionDeniedError) GetCause ¶
func (e *PermissionDeniedError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*PermissionDeniedError) GetCode ¶
func (e *PermissionDeniedError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*PermissionDeniedError) GetMessage ¶
func (e *PermissionDeniedError) GetMessage() string
GetMessage returns the message associated with this error.
func (*PermissionDeniedError) GetStack ¶
func (e *PermissionDeniedError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*PermissionDeniedError) Temporary ¶
func (e *PermissionDeniedError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*PermissionDeniedError) Timeout ¶
func (e *PermissionDeniedError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type ResourceExhaustedError ¶
type ResourceExhaustedError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
ResourceExhaustedError indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
A litmus test that may help a service implementor in deciding between ResourceExhaustedError, UnavailableError, and AbortedError:
(a) Use ResourceExhaustedError for client errors like exceeding allowed rate limits. The client may retry the failing call after they have resolved the causal issue. (b) Use UnavailableError for server errors like inability to accomodate current load or planned server maintenance. The client may retry the failing call. (c) Use AbortedError if the client should retry at a higher-level (e.g., restarting a read-modify-write sequence).
Example error Message:
RESOURCE EXHAUSTED. Quota limit 'xxx' exceeded.
HTTP Mapping: 429 TOO MANY REQUESTS
RPC Mapping: RESOURCE_EXHAUSTED
func NewResourceExhaustedError ¶
func NewResourceExhaustedError(Message string, cause ...error) *ResourceExhaustedError
NewResourceExhaustedError returns a new ResourceExhaustedError.
func (*ResourceExhaustedError) Error ¶
func (e *ResourceExhaustedError) Error() string
Error implements the error interface
func (*ResourceExhaustedError) GRPCStatus ¶
func (e *ResourceExhaustedError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*ResourceExhaustedError) GetCause ¶
func (e *ResourceExhaustedError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*ResourceExhaustedError) GetCode ¶
func (e *ResourceExhaustedError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*ResourceExhaustedError) GetMessage ¶
func (e *ResourceExhaustedError) GetMessage() string
GetMessage returns the message associated with this error.
func (*ResourceExhaustedError) GetStack ¶
func (e *ResourceExhaustedError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*ResourceExhaustedError) Temporary ¶
func (e *ResourceExhaustedError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*ResourceExhaustedError) Timeout ¶
func (e *ResourceExhaustedError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type UnauthenticatedError ¶
type UnauthenticatedError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
UnauthenticatedError indicates the request does not have valid authentication credentials for the operation.
Example error Message:
UNAUTHENTICATED. Invalid authentication credentials.
HTTP Mapping: 401 UNAUTHORIZED
RPC Mapping: UNAUTHENTICATED
func NewUnauthenticatedError ¶
func NewUnauthenticatedError(Message string, cause ...error) *UnauthenticatedError
NewUnauthenticatedError returns a new UnauthenticatedError.
func (*UnauthenticatedError) Error ¶
func (e *UnauthenticatedError) Error() string
Error implements the error interface
func (*UnauthenticatedError) GRPCStatus ¶
func (e *UnauthenticatedError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*UnauthenticatedError) GetCause ¶
func (e *UnauthenticatedError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*UnauthenticatedError) GetCode ¶
func (e *UnauthenticatedError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*UnauthenticatedError) GetMessage ¶
func (e *UnauthenticatedError) GetMessage() string
GetMessage returns the message associated with this error.
func (*UnauthenticatedError) GetStack ¶
func (e *UnauthenticatedError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*UnauthenticatedError) Temporary ¶
func (e *UnauthenticatedError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*UnauthenticatedError) Timeout ¶
func (e *UnauthenticatedError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type UnavailableError ¶
type UnavailableError struct { // contains filtered or unexported fields }
UnavailableError indicates the service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.
A litmus test that may help a service implementor in deciding between ResourceExhaustedError, UnavailableError, and AbortedError:
(a) Use ResourceExhaustedError for client errors like exceeding allowed rate limits. The client may retry the failing call after they have resolved the causal issue. (b) Use UnavailableError for server errors like inability to accomodate current load or planned server maintenance. The client may retry the failing call. (c) Use AbortedError if the client should retry at a higher-level (e.g., restarting a read-modify-write sequence).
Since the client cannot fix this server error, it is not useful to generate additional error details. To avoid leaking sensitive information under error conditions, only a generic error Message is marshalled to JSON or returned via GRPC status.
Error Message:
UNAVAILABLE. Unable to handle the request due to a temporary overloading or maintenance.
HTTP Mapping: 503 SERVICE UNAVAILABLE
RPC Mapping: UNAVAILABLE
func NewUnavailableError ¶
func NewUnavailableError(Message string, cause ...error) *UnavailableError
NewUnavailableError returns a new UnavailableError.
func (*UnavailableError) Error ¶
func (e *UnavailableError) Error() string
Error implements the error interface
func (*UnavailableError) GRPCStatus ¶
func (e *UnavailableError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*UnavailableError) GetCause ¶
func (e *UnavailableError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*UnavailableError) GetCode ¶
func (e *UnavailableError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*UnavailableError) GetMessage ¶
func (e *UnavailableError) GetMessage() string
GetMessage returns the message associated with this error.
func (*UnavailableError) GetStack ¶
func (e *UnavailableError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*UnavailableError) Temporary ¶
func (e *UnavailableError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*UnavailableError) Timeout ¶
func (e *UnavailableError) Timeout() bool
Timeout indicates if this error is the result of a timeout.
type UnknownError ¶
type UnknownError struct { Code int `json:"errorCode"` Message string `json:"errorMessage"` // contains filtered or unexported fields }
UnknownError is an unknown server error. An example of where this error may be returned is if a Status value received from another address space belongs to an error-space that is not known in this address space.
A litmus test that may help a service implementor in deciding between UnknownError and InternalError:
(a) Use UnknownError for generic server-side errors that may be recoverable (UnknownError.Temporary() will return true). (b) Use InternalError for generic server-side errors that are not recoverable (InternalError.Temporary() will return false).
Since the client cannot fix this server error, it is not useful to generate additional error details. To avoid leaking sensitive information under error conditions, only a generic error Message is marshalled to JSON or returned via GRPC status.
Error Message:
UNKNOWN ERROR.
HTTP Mapping: 500 INTERNAL SERVER ERROR
RPC Mapping: UNKNOWN
func NewUnknownError ¶
func NewUnknownError(Message string, cause ...error) *UnknownError
NewUnknownError returns a new UnknownError.
func (*UnknownError) Error ¶
func (e *UnknownError) Error() string
Error implements the error interface
func (*UnknownError) GRPCStatus ¶
func (e *UnknownError) GRPCStatus() *status.Status
GRPCStatus implements an interface required to return proper GRPC status codes
func (*UnknownError) GetCause ¶
func (e *UnknownError) GetCause() error
GetCause returns any causal errors associated with this error.
func (*UnknownError) GetCode ¶
func (e *UnknownError) GetCode() int
GetCode returns the HTTP status code associated with this error.
func (*UnknownError) GetMessage ¶
func (e *UnknownError) GetMessage() string
GetMessage returns the message associated with this error.
func (*UnknownError) GetStack ¶
func (e *UnknownError) GetStack() stack
GetStack returns the trace stack associated with this error.
func (*UnknownError) Temporary ¶
func (e *UnknownError) Temporary() bool
Temporary indicates if this error is potentially recoverable.
func (*UnknownError) Timeout ¶
func (e *UnknownError) Timeout() bool
Timeout indicates if this error is the result of a timeout.