Documentation
¶
Index ¶
- Constants
- Variables
- func CustomErrorHandler(ctx context.Context, gtw *runtime.ServeMux, runtimeMarshaler runtime.Marshaler, ...)
- func Logger(err error) *zerolog.Logger
- type AsertoError
- func (e *AsertoError) Cause() error
- func (e *AsertoError) Copy() *AsertoError
- func (e *AsertoError) Ctx(ctx context.Context) error
- func (e *AsertoError) Data() map[string]string
- func (e *AsertoError) Err(err error) *AsertoError
- func (e *AsertoError) Error() string
- func (e *AsertoError) ErrorInfo(reason string) *errdetails.ErrorInfo
- func (e *AsertoError) Fields() map[string]any
- func (e *AsertoError) GRPCStatus() *status.Status
- func (e *AsertoError) MarshalZerologObject(event *zerolog.Event)
- func (e *AsertoError) Msg(message string) *AsertoError
- func (e *AsertoError) Msgf(message string, args ...any) *AsertoError
- func (e *AsertoError) Str(key, value string) *AsertoError
- func (e *AsertoError) Unwrap() error
- type ContextError
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 ¶
Types ¶
type AsertoError ¶
type AsertoError struct {
Code string
GRPCCode codes.Code
HTTPCode int
Message string
// 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
FromGRPCStatus 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 UnwrapAsertoError ¶
func UnwrapAsertoError(err error) *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) Err ¶
func (e *AsertoError) Err(err error) *AsertoError
Err associates err with the AsertoError, replacing any error previously associated via Err.
func (*AsertoError) Error ¶
func (e *AsertoError) Error() string
func (*AsertoError) ErrorInfo ¶ added in v0.34.1
func (e *AsertoError) ErrorInfo(reason string) *errdetails.ErrorInfo
ErrorInfo returns the errdetails.ErrorInfo for this error, with HTTPCode folded into Metadata under HTTPStatusErrorMetadata so it survives the grpc-gateway boundary (see CustomErrorHandler).
func (*AsertoError) Fields ¶
func (e *AsertoError) Fields() map[string]any
func (*AsertoError) GRPCStatus ¶
func (e *AsertoError) GRPCStatus() *status.Status
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 ...any) *AsertoError
func (*AsertoError) Str ¶
func (e *AsertoError) Str(key, value string) *AsertoError
func (*AsertoError) Unwrap ¶
func (e *AsertoError) Unwrap() error
type ContextError ¶ added in v0.0.8
ContextError represents a standard error that can also encapsulate a context.
func WithContext ¶ added in v0.0.8
func WithContext(err error, ctx context.Context) *ContextError
func WrapContext ¶ added in v0.0.8
func WrapContext(err error, ctx context.Context, message string) *ContextError
func WrapfContext ¶ added in v0.0.8
func (*ContextError) Cause ¶ added in v0.0.8
func (ce *ContextError) Cause() error
func (*ContextError) Error ¶ added in v0.0.8
func (ce *ContextError) Error() string
func (*ContextError) Unwrap ¶ added in v0.0.8
func (ce *ContextError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.