errors

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 12

README

errors - define, construct and manage service errors

Documentation

Index

Constants

View Source
const (
	HTTPStatusErrorMetadata = "aserto-http-statuscode"
)
View Source
const (
	MessageKey = "msg"
)

Variables

View Source
var (
	ErrUnknown = NewAsertoError("E00000", codes.Internal, http.StatusInternalServerError, "an unknown error has occurred")
)

Functions

func CustomErrorHandler

func CustomErrorHandler(ctx context.Context, gtw *runtime.ServeMux, runtimeMarshaler runtime.Marshaler, httpResponseWriter http.ResponseWriter, httpRequest *http.Request, err error)

func Equals

func Equals(err1, err2 error) bool

Returns true if the given errors are Aserto errors with the same code or both of them are nil.

Types

type AsertoError

type AsertoError struct {
	Code       string
	StatusCode codes.Code
	Message    string
	HTTPCode   int
	// contains filtered or unexported fields
}

AsertoError represents a well known error coming from an Aserto service.

func CodeToAsertoError

func CodeToAsertoError(code string) *AsertoError

func FromGRPCStatus

func FromGRPCStatus(grpcStatus status.Status) *AsertoError

Returns an Aserto error based on a given grpcStatus. The details that are not of type errdetails.ErrorInfo are dropped. and if there are details from multiple errors, the aserto error will be constructed based on the first one.

func NewAsertoError

func NewAsertoError(code string, statusCode codes.Code, httpCode int, msg string) *AsertoError

func UnwrapAsertoError

func UnwrapAsertoError(err error) *AsertoError

func (*AsertoError) Bool

func (e *AsertoError) Bool(key string, value bool) *AsertoError

func (*AsertoError) Cause

func (e *AsertoError) Cause() error

func (*AsertoError) Copy

func (e *AsertoError) Copy() *AsertoError

func (*AsertoError) Data

func (e *AsertoError) Data() map[string]string

func (*AsertoError) Duration

func (e *AsertoError) Duration(key string, value time.Duration) *AsertoError

func (*AsertoError) Err

func (e *AsertoError) Err(err error) *AsertoError

Associates err with the AsertoError.

func (*AsertoError) Error

func (e *AsertoError) Error() string

func (*AsertoError) Fields

func (e *AsertoError) Fields() map[string]interface{}

func (*AsertoError) FromReader

func (e *AsertoError) FromReader(key string, value io.Reader) *AsertoError

func (*AsertoError) GRPCStatus

func (e *AsertoError) GRPCStatus() *status.Status

func (*AsertoError) Int

func (e *AsertoError) Int(key string, value int) *AsertoError

func (*AsertoError) Int32

func (e *AsertoError) Int32(key string, value int32) *AsertoError

func (*AsertoError) Int64

func (e *AsertoError) Int64(key string, value int64) *AsertoError

func (*AsertoError) Interface

func (e *AsertoError) Interface(key string, value interface{}) *AsertoError

func (*AsertoError) MarshalZerologObject

func (e *AsertoError) MarshalZerologObject(event *zerolog.Event)

func (*AsertoError) Msg

func (e *AsertoError) Msg(message string) *AsertoError

func (*AsertoError) Msgf

func (e *AsertoError) Msgf(message string, args ...interface{}) *AsertoError

func (*AsertoError) SameAs

func (e *AsertoError) SameAs(err error) bool

SameAs returns true if the provided error is an AsertoError and has the same error code.

func (*AsertoError) Str

func (e *AsertoError) Str(key, value string) *AsertoError

func (*AsertoError) Time

func (e *AsertoError) Time(key string, value time.Time) *AsertoError

func (*AsertoError) Unwrap

func (e *AsertoError) Unwrap() error

func (*AsertoError) WithGRPCStatus

func (e *AsertoError) WithGRPCStatus(grpcCode codes.Code) *AsertoError

func (*AsertoError) WithHTTPStatus

func (e *AsertoError) WithHTTPStatus(httpStatus int) *AsertoError

Jump to

Keyboard shortcuts

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