errhandling

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QuotaReached = "QuotaReached"
	QuotaUnknown = "QuotaUnknown"
)

Variables

This section is empty.

Functions

func HTTPErrorFromGrpcError

func HTTPErrorFromGrpcError(err error) int

func IsStatusLimit

func IsStatusLimit(err error, label string) bool

func IsTransient

func IsTransient(err error) bool

IsTransient returns true if the error was wrapped to indicate its transient. If this function returns true it is safe, but not required, to retry the operation.

func JSONWithHTTPStatus

func JSONWithHTTPStatus(statusCode int, message string) string

func NewB2CErrorHandler

func NewB2CErrorHandler(fallback runtime.ErrorHandlerFunc) runtime.ErrorHandlerFunc

NewB2CErrorHandler returns a handler for Azure format b2c errors.

return a json response in the format defined here: https://docs.microsoft.com/en-us/azure/active-directory-b2c/restful-technical-profile#returning-validation-error-message

func NewHTTPErrorHandler

func NewHTTPErrorHandler(fallback runtime.ErrorHandlerFunc) runtime.ErrorHandlerFunc

func NewTransientError

func NewTransientError(err error) error

NewTransientError creates an Error object that indicates a retry is appropriate. It is up to the consumer to decide whether to retry based on the context of that consumer. Note that crashing out is effectively a retry unless the message is explicitly Completed or DeadLettered first.

func NewTransientErrorf

func NewTransientErrorf(format string, a ...any) error

func SetQuotaReached

func SetQuotaReached(ctx context.Context, tenantID string, name string) error

SetQuotaReached returns a labelled QuotaReached error

func SetQuotaUnknown

func SetQuotaUnknown(ctx context.Context, tenantID string, name string, err error) error

SetQuotaUnknown returns a labelled QuotaUnknown error

func StatusError

func StatusError(ctx context.Context, c codes.Code, fmt string, opts ...any) error

Types

type ErrB2C

type ErrB2C struct {
	// APIVersion is the API version of b2c that we are using
	APIVersion string `json:"version"`

	// Status, http status code. The REST API should return an HTTP 4xx error message
	Status int `json:"status"`

	// UserMessage is the message to the user
	UserMessage string `json:"userMessage"`
}

func GetErrB2c

func GetErrB2c(ctx context.Context, err error) (*ErrB2C, error)

GetErrB2c attempts to get a ErrB2c from an error

func NewErrB2c

func NewErrB2c(status int, format string, a ...any) *ErrB2C

NewErrB2c creates a B2C error given a http status and a user message.

func (*ErrB2C) Error

func (e *ErrB2C) Error() string

Error implements the err interface

func (*ErrB2C) WithErrorString

func (e *ErrB2C) WithErrorString(log Logger, errString string) error

WithErrorString converts a B2C error string into

a b2c error.

type ErrorWithStatus

type ErrorWithStatus struct {
	// contains filtered or unexported fields
}

func NewErrorStatus

func NewErrorStatus(err error, statusCode int) *ErrorWithStatus

func (*ErrorWithStatus) Error

func (e *ErrorWithStatus) Error() string

func (*ErrorWithStatus) StatusCode

func (e *ErrorWithStatus) StatusCode() int

func (*ErrorWithStatus) Unwrap

func (e *ErrorWithStatus) Unwrap() error

type HTTPError

type HTTPError interface {
	Error() string
	StatusCode() int
}

HTTPError error type with info about http.StatusCode

type Logger

type Logger = logger.Logger

type Status

type Status = status.Status

so we dont have to import status package everywhere

func NewStatus

func NewStatus(c codes.Code, format string, args ...any) *Status

func StatusWithQuotaFailure

func StatusWithQuotaFailure(ctx context.Context, subject string, label string, name string) *Status

func StatusWithRequestInfoFromContext

func StatusWithRequestInfoFromContext(ctx context.Context, s *Status) *Status

Jump to

Keyboard shortcuts

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