Documentation ΒΆ
Index ΒΆ
- Variables
- func Errorf(format string, args ...any) error
- func GetPublic(err error, defaultPublicMessage string) string
- func Join(e ...error) error
- func Recover(cb func()) (err error)
- func Recoverf(cb func(), msg string, args ...any) (err error)
- func Wrap(err error) error
- func Wrap10[A any, B any, C any, D any, E any, F any, G any, H any, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I, err error) (A, B, C, D, E, F, G, H, I, error)
- func Wrap2[A any](a A, err error) (A, error)
- func Wrap3[A any, B any](a A, b B, err error) (A, B, error)
- func Wrap4[A any, B any, C any](a A, b B, c C, err error) (A, B, C, error)
- func Wrap5[A any, B any, C any, D any](a A, b B, c C, d D, err error) (A, B, C, D, error)
- func Wrap6[A any, B any, C any, D any, E any](a A, b B, c C, d D, e E, err error) (A, B, C, D, E, error)
- func Wrap7[A any, B any, C any, D any, E any, F any](a A, b B, c C, d D, e E, f F, err error) (A, B, C, D, E, F, error)
- func Wrap8[A any, B any, C any, D any, E any, F any, G any](a A, b B, c C, d D, e E, f F, g G, err error) (A, B, C, D, E, F, G, error)
- func Wrap9[A any, B any, C any, D any, E any, F any, G any, H any](a A, b B, c C, d D, e E, f F, g G, h H, err error) (A, B, C, D, E, F, G, H, error)
- func Wrapf(err error, format string, args ...any) error
- func Wrapf10[A any, B any, C any, D any, E any, F any, G any, H any, I any](a A, b B, c C, d D, e E, f F, g G, h H, i I, err error, format string, ...) (A, B, C, D, E, F, G, H, I, error)
- func Wrapf2[A any](a A, err error, format string, args ...any) (A, error)
- func Wrapf3[A any, B any](a A, b B, err error, format string, args ...any) (A, B, error)
- func Wrapf4[A any, B any, C any](a A, b B, c C, err error, format string, args ...any) (A, B, C, error)
- func Wrapf5[A any, B any, C any, D any](a A, b B, c C, d D, err error, format string, args ...any) (A, B, C, D, error)
- func Wrapf6[A any, B any, C any, D any, E any](a A, b B, c C, d D, e E, err error, format string, args ...any) (A, B, C, D, E, error)
- func Wrapf7[A any, B any, C any, D any, E any, F any](a A, b B, c C, d D, e E, f F, err error, format string, args ...any) (A, B, C, D, E, F, error)
- func Wrapf8[A any, B any, C any, D any, E any, F any, G any](a A, b B, c C, d D, e E, f F, g G, err error, format string, args ...any) (A, B, C, D, E, F, G, error)
- func Wrapf9[A any, B any, C any, D any, E any, F any, G any, H any](a A, b B, c C, d D, e E, f F, g G, h H, err error, format string, args ...any) (A, B, C, D, E, F, G, H, error)
- type OopsError
- func (o OopsError) Code() string
- func (o OopsError) Context() map[string]any
- func (o OopsError) Domain() string
- func (o OopsError) Duration() time.Duration
- func (o OopsError) Error() string
- func (o OopsError) Format(s fmt.State, verb rune)
- func (o OopsError) Hint() string
- func (c OopsError) Is(err error) bool
- func (o OopsError) LogValuer() slog.Value
- func (o OopsError) MarshalJSON() ([]byte, error)
- func (o OopsError) Owner() string
- func (o OopsError) Public() string
- func (o OopsError) Request() *http.Request
- func (o OopsError) Response() *http.Response
- func (o OopsError) Sources() string
- func (o OopsError) Span() string
- func (o OopsError) Stacktrace() string
- func (o OopsError) Tags() []string
- func (o OopsError) Tenant() (string, map[string]any)
- func (o OopsError) Time() time.Time
- func (o OopsError) ToMap() map[string]any
- func (o OopsError) Trace() string
- func (o OopsError) Unwrap() error
- func (o OopsError) User() (string, map[string]any)
- type OopsErrorBuilder
- func Assert(condition bool) OopsErrorBuilder
- func Assertf(condition bool, msg string, args ...any) OopsErrorBuilder
- func Code(code string) OopsErrorBuilder
- func Duration(duration time.Duration) OopsErrorBuilder
- func Hint(hint string) OopsErrorBuilder
- func In(domain string) OopsErrorBuilder
- func Owner(owner string) OopsErrorBuilder
- func Public(public string) OopsErrorBuilder
- func Request(req *http.Request, withBody bool) OopsErrorBuilder
- func Response(res *http.Response, withBody bool) OopsErrorBuilder
- func Since(time time.Time) OopsErrorBuilder
- func Span(span string) OopsErrorBuilder
- func Tags(tags ...string) OopsErrorBuilder
- func Tenant(tenantID string, data map[string]any) OopsErrorBuilder
- func Time(time time.Time) OopsErrorBuilder
- func Trace(trace string) OopsErrorBuilder
- func User(userID string, data map[string]any) OopsErrorBuilder
- func With(kv ...any) OopsErrorBuilder
- func WithContext(ctx context.Context, keys ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) Assert(condition bool) OopsErrorBuilder
- func (o OopsErrorBuilder) Assertf(condition bool, msg string, args ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) Code(code string) OopsErrorBuilder
- func (o OopsErrorBuilder) Duration(duration time.Duration) OopsErrorBuilder
- func (o OopsErrorBuilder) Errorf(format string, args ...any) error
- func (o OopsErrorBuilder) Hint(hint string) OopsErrorBuilder
- func (o OopsErrorBuilder) In(domain string) OopsErrorBuilder
- func (o OopsErrorBuilder) Join(e ...error) error
- func (o OopsErrorBuilder) Owner(owner string) OopsErrorBuilder
- func (o OopsErrorBuilder) Public(public string) OopsErrorBuilder
- func (o OopsErrorBuilder) Recover(cb func()) (err error)
- func (o OopsErrorBuilder) Recoverf(cb func(), msg string, args ...any) (err error)
- func (o OopsErrorBuilder) Request(req *http.Request, withBody bool) OopsErrorBuilder
- func (o OopsErrorBuilder) Response(res *http.Response, withBody bool) OopsErrorBuilder
- func (o OopsErrorBuilder) Since(t time.Time) OopsErrorBuilder
- func (o OopsErrorBuilder) Span(span string) OopsErrorBuilder
- func (o OopsErrorBuilder) Tags(tags ...string) OopsErrorBuilder
- func (o OopsErrorBuilder) Tenant(tenantID string, tenantData ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) Time(time time.Time) OopsErrorBuilder
- func (o OopsErrorBuilder) Trace(trace string) OopsErrorBuilder
- func (o OopsErrorBuilder) User(userID string, userData ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) With(kv ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) WithContext(ctx context.Context, keys ...any) OopsErrorBuilder
- func (o OopsErrorBuilder) Wrap(err error) error
- func (o OopsErrorBuilder) Wrapf(err error, format string, args ...any) error
Constants ΒΆ
This section is empty.
Variables ΒΆ
var ( SourceFragmentsHidden = true DereferencePointers = true Local *time.Location = time.UTC )
var (
StackTraceMaxDepth int = 10
)
Functions ΒΆ
func GetPublic ΒΆ added in v1.13.0
GetPublic returns a message that is safe to show to an end user, or a default generic message.
func Recover ΒΆ
func Recover(cb func()) (err error)
Recover handle panic and returns `oops.OopsError` object that satisfies `error`.
func Recoverf ΒΆ
Recoverf handle panic and returns `oops.OopsError` object that satisfies `error` and formats an error message.
func Wrapf ΒΆ
Wrapf wraps an error into an `oops.OopsError` object that satisfies `error` and formats an error message.
Types ΒΆ
type OopsError ΒΆ
type OopsError struct {
// contains filtered or unexported fields
}
func (OopsError) Code ΒΆ
Code returns the error cause. Error code is intented to be used by machines.
func (OopsError) Format ΒΆ
Format implements fmt.Formatter. If the format is "%+v", then the details of the error are included. Otherwise, using "%v", just the summary is included.
func (OopsError) MarshalJSON ΒΆ
MarshalJSON implements json.Marshaler.
func (OopsError) Public ΒΆ added in v1.13.0
Public returns a message that is safe to show to an end user.
func (OopsError) Stacktrace ΒΆ
Stacktrace returns a pretty printed stacktrace of the error.
type OopsErrorBuilder ΒΆ
type OopsErrorBuilder OopsError
*
- Builder pattern. *
- oops.Errorf("Could not fetch users: %w", err) *
- oops.
- User("steve@apple.com", "firstname", "Samuel").
- Tenant("apple", "country", "us").
- Errorf("403 not permitted") *
- oops.
- Time(requestDate).
- Duration(requestDuration).
- Tx(traceID).
- Errorf("Failed to execute http request") *
- oops.
- With("project_id", project.ID, "created_at", project.CreatedAt).
- Errorf("Could not update settings") *
func Assert ΒΆ added in v1.1.0
func Assert(condition bool) OopsErrorBuilder
Assert panics if condition is false. Panic payload will be of type oops.OopsError. Assertions can be chained.
func Assertf ΒΆ added in v1.1.0
func Assertf(condition bool, msg string, args ...any) OopsErrorBuilder
Assertf panics if condition is false. Panic payload will be of type oops.OopsError. Assertions can be chained.
func Code ΒΆ
func Code(code string) OopsErrorBuilder
Code set a code or slug that describes the error. Error messages are intented to be read by humans, but such code is expected to be read by machines and even transported over different services.
func Duration ΒΆ
func Duration(duration time.Duration) OopsErrorBuilder
Duration set the error duration.
func Owner ΒΆ
func Owner(owner string) OopsErrorBuilder
Owner set the name/email of the collegue/team responsible for handling this error. Useful for alerting purpose.
func Public ΒΆ added in v1.13.1
func Public(public string) OopsErrorBuilder
Public sets a message that is safe to show to an end user.
func Request ΒΆ added in v1.3.0
func Request(req *http.Request, withBody bool) OopsErrorBuilder
Request supplies a http.Request.
func Response ΒΆ added in v1.3.0
func Response(res *http.Response, withBody bool) OopsErrorBuilder
Response supplies a http.Response.
func Tags ΒΆ
func Tags(tags ...string) OopsErrorBuilder
Tags adds multiple tags, describing the feature returning an error.
func Tenant ΒΆ
func Tenant(tenantID string, data map[string]any) OopsErrorBuilder
Tenant supplies tenant id and a chain of key/value.
func Time ΒΆ
func Time(time time.Time) OopsErrorBuilder
Time set the error time. Default: `time.Now()`
func Trace ΒΆ
func Trace(trace string) OopsErrorBuilder
Trace set a transaction id, trace id or correlation id...
func User ΒΆ
func User(userID string, data map[string]any) OopsErrorBuilder
User supplies user id and a chain of key/value.
func With ΒΆ
func With(kv ...any) OopsErrorBuilder
With supplies a list of attributes declared by pair of key+value.
func WithContext ΒΆ added in v1.8.0
func WithContext(ctx context.Context, keys ...any) OopsErrorBuilder
With supplies a list of attributes declared by pair of key+value.
func (OopsErrorBuilder) Assert ΒΆ added in v1.1.0
func (o OopsErrorBuilder) Assert(condition bool) OopsErrorBuilder
Assert panics if condition is false. Panic payload will be of type oops.OopsError. Assertions can be chained.
func (OopsErrorBuilder) Assertf ΒΆ added in v1.1.0
func (o OopsErrorBuilder) Assertf(condition bool, msg string, args ...any) OopsErrorBuilder
Assertf panics if condition is false. Panic payload will be of type oops.OopsError. Assertions can be chained.
func (OopsErrorBuilder) Code ΒΆ
func (o OopsErrorBuilder) Code(code string) OopsErrorBuilder
Code set a code or slug that describes the error. Error messages are intented to be read by humans, but such code is expected to be read by machines and even transported over different services.
func (OopsErrorBuilder) Duration ΒΆ
func (o OopsErrorBuilder) Duration(duration time.Duration) OopsErrorBuilder
Duration set the error duration.
func (OopsErrorBuilder) Errorf ΒΆ
func (o OopsErrorBuilder) Errorf(format string, args ...any) error
Errorf formats an error and returns `oops.OopsError` object that satisfies `error`.
func (OopsErrorBuilder) Hint ΒΆ
func (o OopsErrorBuilder) Hint(hint string) OopsErrorBuilder
Hint set a hint for faster debugging.
func (OopsErrorBuilder) In ΒΆ
func (o OopsErrorBuilder) In(domain string) OopsErrorBuilder
In set the feature category or domain.
func (OopsErrorBuilder) Join ΒΆ added in v1.12.0
func (o OopsErrorBuilder) Join(e ...error) error
func (OopsErrorBuilder) Owner ΒΆ
func (o OopsErrorBuilder) Owner(owner string) OopsErrorBuilder
Owner set the name/email of the collegue/team responsible for handling this error. Useful for alerting purpose.
func (OopsErrorBuilder) Public ΒΆ added in v1.13.0
func (o OopsErrorBuilder) Public(public string) OopsErrorBuilder
Public represents a message that is safe to be shown to an end-user.
func (OopsErrorBuilder) Recover ΒΆ
func (o OopsErrorBuilder) Recover(cb func()) (err error)
Recover handle panic and returns `oops.OopsError` object that satisfies `error`.
func (OopsErrorBuilder) Recoverf ΒΆ
func (o OopsErrorBuilder) Recoverf(cb func(), msg string, args ...any) (err error)
Recoverf handle panic and returns `oops.OopsError` object that satisfies `error` and formats an error message.
func (OopsErrorBuilder) Request ΒΆ added in v1.3.0
func (o OopsErrorBuilder) Request(req *http.Request, withBody bool) OopsErrorBuilder
Request supplies a http.Request.
func (OopsErrorBuilder) Response ΒΆ added in v1.3.0
func (o OopsErrorBuilder) Response(res *http.Response, withBody bool) OopsErrorBuilder
Response supplies a http.Response.
func (OopsErrorBuilder) Since ΒΆ
func (o OopsErrorBuilder) Since(t time.Time) OopsErrorBuilder
Since set the error duration.
func (OopsErrorBuilder) Span ΒΆ
func (o OopsErrorBuilder) Span(span string) OopsErrorBuilder
Span represents a unit of work or operation.
func (OopsErrorBuilder) Tags ΒΆ
func (o OopsErrorBuilder) Tags(tags ...string) OopsErrorBuilder
Tags adds multiple tags, describing the feature returning an error.
func (OopsErrorBuilder) Tenant ΒΆ
func (o OopsErrorBuilder) Tenant(tenantID string, tenantData ...any) OopsErrorBuilder
Tenant supplies tenant id and a chain of key/value.
func (OopsErrorBuilder) Time ΒΆ
func (o OopsErrorBuilder) Time(time time.Time) OopsErrorBuilder
Time set the error time. Default: `time.Now()`
func (OopsErrorBuilder) Trace ΒΆ
func (o OopsErrorBuilder) Trace(trace string) OopsErrorBuilder
Trace set a transaction id, trace id or correlation id...
func (OopsErrorBuilder) User ΒΆ
func (o OopsErrorBuilder) User(userID string, userData ...any) OopsErrorBuilder
User supplies user id and a chain of key/value.
func (OopsErrorBuilder) With ΒΆ
func (o OopsErrorBuilder) With(kv ...any) OopsErrorBuilder
With supplies a list of attributes declared by pair of key+value.
func (OopsErrorBuilder) WithContext ΒΆ added in v1.8.0
func (o OopsErrorBuilder) WithContext(ctx context.Context, keys ...any) OopsErrorBuilder
WithContext supplies a list of values declared in context.
func (OopsErrorBuilder) Wrap ΒΆ
func (o OopsErrorBuilder) Wrap(err error) error
Wrap wraps an error into an `oops.OopsError` object that satisfies `error`