errorx

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorAsGRPCStatus

func ErrorAsGRPCStatus(err error) *grpcStatus.Status

ErrorAsGRPCStatus generates a new Status from the given generic error. If there is a GRPCStatus-compatible error wrapped inside, that type and details are used to generate the new status. If there is a problem encoding the details, an Internal error is thrown. The message is retrieved from the outermost error. Non-errorx errors are given the Unknown error type.

func LogAndSetHTTPError

func LogAndSetHTTPError(ctx context.Context, w http.ResponseWriter, log log.Logger, err error)

LogAndSetHTTPError logs the provided error and then translates the internal error into a http response. The error message set in the response is conservative in an attempt to prevent internal details (e.g. GCS bucket name) from leaking. If the error is from this errorx package, the top-level message is logged. Otherwise, hardcoded messages are returned

func WithErrorxTypeDetail

func WithErrorxTypeDetail(s *grpcStatus.Status, details ...protov1.Message) *grpcStatus.Status

Types

type BadRequest

type BadRequest struct {
	Msg string
	Err error
}

func (BadRequest) Error

func (e BadRequest) Error() string

func (BadRequest) GRPCStatus

func (e BadRequest) GRPCStatus() *grpcStatus.Status

func (BadRequest) GRPCStatusDetails

func (e BadRequest) GRPCStatusDetails() []protov1.Message

func (BadRequest) HTTPStatusCode

func (e BadRequest) HTTPStatusCode() int

func (BadRequest) Message

func (e BadRequest) Message() string

func (BadRequest) Unwrap

func (e BadRequest) Unwrap() error

type Conflict

type Conflict struct {
	Msg string
	Err error
}

func (Conflict) Error

func (e Conflict) Error() string

func (Conflict) GRPCStatus

func (e Conflict) GRPCStatus() *grpcStatus.Status

func (Conflict) GRPCStatusDetails

func (e Conflict) GRPCStatusDetails() []protov1.Message

func (Conflict) HTTPStatusCode

func (e Conflict) HTTPStatusCode() int

func (Conflict) Message

func (e Conflict) Message() string

func (Conflict) Unwrap

func (e Conflict) Unwrap() error

type Disabled

type Disabled struct{}

func (Disabled) Error

func (e Disabled) Error() string

func (Disabled) GRPCStatus

func (e Disabled) GRPCStatus() *grpcStatus.Status

func (Disabled) GRPCStatusDetails

func (e Disabled) GRPCStatusDetails() []protov1.Message

func (Disabled) HTTPStatusCode

func (e Disabled) HTTPStatusCode() int

func (Disabled) Message

func (e Disabled) Message() string

type Error

type Error interface {
	error
	HTTPStatusCode() int
	Message() string
	GRPCStatus() *grpcStatus.Status
	GRPCStatusDetails() []protov1.Message
}

func FromGRPCStatus

func FromGRPCStatus(s *grpcStatus.Status) Error

FromGRPCStatus converts a Status to a native Error type. The GRPC Status type is ignored in this conversion -- instead we expect ErrorDetails to be included naming the correct internal type. Statuses without details will be returned as Internal errors.

type Internal

type Internal struct {
	Msg string
	Err error
}

func (Internal) Error

func (e Internal) Error() string

func (Internal) GRPCStatus

func (e Internal) GRPCStatus() *grpcStatus.Status

func (Internal) GRPCStatusDetails

func (e Internal) GRPCStatusDetails() []protov1.Message

func (Internal) HTTPStatusCode

func (e Internal) HTTPStatusCode() int

func (Internal) Message

func (e Internal) Message() string

func (Internal) Unwrap

func (e Internal) Unwrap() error

type RateLimited

type RateLimited struct {
	Msg string
	Err error
}

func (RateLimited) Error

func (e RateLimited) Error() string

func (RateLimited) GRPCStatus

func (e RateLimited) GRPCStatus() *grpcStatus.Status

func (RateLimited) GRPCStatusDetails

func (e RateLimited) GRPCStatusDetails() []protov1.Message

func (RateLimited) HTTPStatusCode

func (e RateLimited) HTTPStatusCode() int

func (RateLimited) Message

func (e RateLimited) Message() string

func (RateLimited) Unwrap

func (e RateLimited) Unwrap() error

type RequiresProxyRequest

type RequiresProxyRequest struct {
	Msg string
	Err error
	// Reason field should be a low cardinality value, used for labeling metrics.
	Reason string
}

RequiresProxyRequest signifies the request could not be completed locally (eg. unsupported target function), so should be forwarded to the appropriate proxy.

func (RequiresProxyRequest) Error

func (e RequiresProxyRequest) Error() string

func (RequiresProxyRequest) GRPCStatus

func (e RequiresProxyRequest) GRPCStatus() *grpcStatus.Status

func (RequiresProxyRequest) GRPCStatusDetails

func (e RequiresProxyRequest) GRPCStatusDetails() []protov1.Message

func (RequiresProxyRequest) HTTPStatusCode

func (e RequiresProxyRequest) HTTPStatusCode() int

func (RequiresProxyRequest) Message

func (e RequiresProxyRequest) Message() string

func (RequiresProxyRequest) Unwrap

func (e RequiresProxyRequest) Unwrap() error

type TooManyRequests

type TooManyRequests struct {
	Msg string
	Err error
}

func (TooManyRequests) Error

func (e TooManyRequests) Error() string

func (TooManyRequests) GRPCStatus

func (e TooManyRequests) GRPCStatus() *grpcStatus.Status

func (TooManyRequests) GRPCStatusDetails

func (e TooManyRequests) GRPCStatusDetails() []protov1.Message

func (TooManyRequests) HTTPStatusCode

func (e TooManyRequests) HTTPStatusCode() int

func (TooManyRequests) Message

func (e TooManyRequests) Message() string

func (TooManyRequests) Unwrap

func (e TooManyRequests) Unwrap() error

type Unimplemented

type Unimplemented struct {
	Msg string
}

func (Unimplemented) Error

func (e Unimplemented) Error() string

func (Unimplemented) GRPCStatus

func (e Unimplemented) GRPCStatus() *grpcStatus.Status

func (Unimplemented) GRPCStatusDetails

func (e Unimplemented) GRPCStatusDetails() []protov1.Message

func (Unimplemented) HTTPStatusCode

func (e Unimplemented) HTTPStatusCode() int

func (Unimplemented) Message

func (e Unimplemented) Message() string

type UnprocessableEntity

type UnprocessableEntity struct {
	Msg string
}

func (UnprocessableEntity) Error

func (e UnprocessableEntity) Error() string

func (UnprocessableEntity) GRPCStatus

func (e UnprocessableEntity) GRPCStatus() *grpcStatus.Status

func (UnprocessableEntity) GRPCStatusDetails

func (e UnprocessableEntity) GRPCStatusDetails() []protov1.Message

func (UnprocessableEntity) HTTPStatusCode

func (e UnprocessableEntity) HTTPStatusCode() int

func (UnprocessableEntity) Message

func (e UnprocessableEntity) Message() string

type UnsupportedMediaType

type UnsupportedMediaType struct {
	Msg string
	Err error
}

func (UnsupportedMediaType) Error

func (e UnsupportedMediaType) Error() string

func (UnsupportedMediaType) GRPCStatus

func (e UnsupportedMediaType) GRPCStatus() *grpcStatus.Status

func (UnsupportedMediaType) GRPCStatusDetails

func (e UnsupportedMediaType) GRPCStatusDetails() []protov1.Message

func (UnsupportedMediaType) HTTPStatusCode

func (e UnsupportedMediaType) HTTPStatusCode() int

func (UnsupportedMediaType) Message

func (e UnsupportedMediaType) Message() string

func (UnsupportedMediaType) Unwrap

func (e UnsupportedMediaType) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL