Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorToZeroLog(err error) *zerolog.Event
- func ErrorsToZeroLog(errs []error) *zerolog.Array
- func PanicOnErr(err error)
- func PanicOnErrVal[T any](val T, err error) T
- func PanicOnErrValExceptNoRows[T any](val T, err error) T
- func WarnOnErr(err error)
- func WarnOnErrVal[T any](val T, err error) T
- type Error
- func (ae *Error) AddFlag(f ErrorFlags) *Error
- func (ae *Error) AddLogContext(key string, val any) *Error
- func (ae *Error) AddMessage(msg string) *Error
- func (ae *Error) Error() string
- func (ae *Error) HasFlag(f ErrorFlags) bool
- func (ae *Error) HttpError(code int) *Error
- func (ae *Error) IsNil() bool
- func (ae *Error) TakeStackTrace(stackTrace []byte) *Error
- func (ae *Error) WithStackTrace() *Error
- func (ae *Error) Wrap(err error) *Error
- type ErrorFlags
- type LogKV
- type Task
- func (nc *Task) AddLogContext(key string, value any)
- func (nc *Task) AddToLogContextList(key, str string)
- func (nc *Task) AddWarning(err error)
- func (nc *Task) AddWarningStr(msg string)
- func (nc *Task) SetRequestID(requestID string)
- func (nc *Task) SetTraceID(traceID string)
- func (nc *Task) ToZeroLog() *zerolog.Event
- func (nc *Task) WrapErrorsAndPanics(f func() error) (reterr error)
Constants ¶
View Source
const ( DevEnv string = "dev" StagingEnv string = "staging" TestEnv string = "test" ProdEnv string = "prod" )
Variables ¶
View Source
var Env string
Functions ¶
func ErrorToZeroLog ¶
func ErrorsToZeroLog ¶
func PanicOnErr ¶
func PanicOnErr(err error)
func PanicOnErrVal ¶
func WarnOnErrVal ¶
Types ¶
type Error ¶
type Error struct {
HttpCode int
UserMessages []string
WrappedError error
ErrorLogContext LogKV
StackTrace []string
Flags ErrorFlags
}
func NewHttpError ¶
func NewWrappedError ¶
func (*Error) AddFlag ¶
func (ae *Error) AddFlag(f ErrorFlags) *Error
func (*Error) AddMessage ¶
func (*Error) HasFlag ¶
func (ae *Error) HasFlag(f ErrorFlags) bool
func (*Error) TakeStackTrace ¶
func (*Error) WithStackTrace ¶
type Task ¶
type Task struct {
context.Context
TraceID string // HTTP's request_id or Job's trace_id
LogItems LogKV
Log zerolog.Logger
Warnings []error
}
Stores everything needed to perform one task, eg. run one job or perform one HTTP request
func (*Task) AddLogContext ¶
func (*Task) AddToLogContextList ¶
func (*Task) AddWarning ¶
func (*Task) AddWarningStr ¶
func (*Task) SetRequestID ¶
func (*Task) SetTraceID ¶
func (*Task) WrapErrorsAndPanics ¶
Click to show internal directories.
Click to hide internal directories.