errorw

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Render func(e *Error) string

Functions

func PlainRender

func PlainRender(e *Error) string

Types

type Error

type Error struct {
	Err     error
	Stack   *stack
	Wrapper []string
	Fields  map[string]interface{}

	APIErrors []*status.Status
}

Error wrap error with fields and stack

func New

func New(err error) *Error

New create an error

func NewAPIError

func NewAPIError(apiError *status.Status) *Error

NewAPIError create an error and append API error.

func NewMessage

func NewMessage(message string) *Error

NewMessage create an error with message.

func NewMessagef

func NewMessagef(format string, args ...interface{}) *Error

NewMessagef create an error with message. It will formats according to a format specifier and returns the resulting string.

func Wrap

func Wrap(err error, message string) *Error

Wrap wrap message

func Wrapf added in v1.1.0

func Wrapf(err error, format string, args ...interface{}) *Error

Wrapf wrap message with formats.

func (*Error) APIErrorCause

func (e *Error) APIErrorCause() *status.Status

APIErrorCause return the root cause of the API error.

func (*Error) Cause

func (e *Error) Cause() error

Cause implement errors.Cause interface.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GRPCStatus

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

GRPCStatus return the internal error's gRPC status or the root cause of the API error. Priority returns the internal error's gRPC status if it implements status.GRPCStatus. If no gRPC status can be use, then create a gRPC status with internal error. Implement gRPC status.GRPCStatus function.

func (*Error) MarshalLogObject

func (e *Error) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is an implementation of `zapcore.ObjectMarshaler` interface

func (*Error) StackTrace

func (e *Error) StackTrace() errors.StackTrace

StackTrace implement `github.com/pkg/errors` stackTracer interface. To make the `sentry-go` `extractReflectedStacktraceMethod()` works

func (*Error) WithAPIError

func (e *Error) WithAPIError(apiError *status.Status) *Error

WithAPIError append API error to error

func (*Error) WithField

func (e *Error) WithField(key string, value interface{}) *Error

WithField append key/value to error

func (*Error) WithFields

func (e *Error) WithFields(fields map[string]interface{}) *Error

WithFields append fields to error. Parameter fields will cover value which key is already exists.

func (*Error) WithWrap

func (e *Error) WithWrap(message string) *Error

WithWrap wrap message to error

Jump to

Keyboard shortcuts

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