zen/core/zerr/wrap.go

42 lines
793 B
Go

package zerr
import (
"context"
"time"
"gitlab.bareksa.com/backend/zen/core/zoptions"
)
type WrapInitialInput struct {
Error error
Message string
PC uintptr
Time time.Time
Logger Logger
Notifier Notifier
}
type Wrapper interface {
// Wrap creates a zerr.Error with inputs
// generated by global entry points.
Wrap(input WrapInitialInput) Error
}
type Logger interface {
LogError(ctx context.Context, err Error)
}
type Notifier interface {
NotifyError(ctx context.Context, err Error, opts ...zoptions.NotifyOption)
}
type WrapperFunc func(input WrapInitialInput) Error
func (wr WrapperFunc) Wrap(input WrapInitialInput) Error {
return wr(input)
}
var DefaultWrapper Wrapper = WrapperFunc(func(input WrapInitialInput) Error {
panic("not implemented")
})