zen/core/zerr/wrap.go

42 lines
783 B
Go
Raw Normal View History

2024-08-22 17:26:53 +07:00
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 {
Log(ctx context.Context, err Error)
}
type Notifier interface {
Notify(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")
})