Documentation ¶
Overview ¶
Package grr provides a set of error handling helpers for Go.
Index ¶
- func CallerInfo() string
- func Ignore1[T any](v T, err error) T
- func Ignore2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)
- func Ignore3[T1, T2, T3 any](v1 T1, v2 T2, v3 T3, err error) (T1, T2, T3)
- func Log(err error) error
- func Log1[T any](v T, err error) T
- func Log2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)
- func Log3[T1, T2, T3 any](v1 T1, v2 T2, v3 T3, err error) (T1, T2, T3)
- func Must(err error)
- func Must1[T any](v T, err error) T
- func Must2[T1, T2 any](v1 T1, v2 T2, err error) (T1, T2)
- func Must3[T1, T2, T3 any](v1 T1, v2 T2, v3 T3, err error) (T1, T2, T3)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerInfo ¶ added in v0.0.8
func CallerInfo() string
CallerInfo returns string information about the caller of the function that called CallerInfo.
func Ignore1 ¶
Ignore1 ignores an error return value for a function returning a value and an error, allowing direct usage of the value. The intended usage is:
a := grr.Ignore1(MyFunc(v))
func Ignore2 ¶
Ignore2 ignores an error return value for a function returning two values and an error, allowing direct usage of the values. The intended usage is:
a, b := grr.Ignore2(MyFunc(v))
func Ignore3 ¶
Ignore3 ignores an error return value for a function returning three values and an error, allowing direct usage of the values. The intended usage is:
a, b, c := grr.Ignore3(MyFunc(v))
func Log ¶
Log takes the given error and logs it if it is non-nil. The intended usage is:
grr.Log(MyFunc(v)) // or return grr.Log(MyFunc(v))
func Log1 ¶
Log1 takes the given value and error and returns the value if the error is nil, and logs the error and returns a zero value if the error is non-nil. The intended usage is:
a := grr.Log1(MyFunc(v))
func Log2 ¶
Log2 takes the given two values and error and returns the values if the error is nil, and logs the error and returns zero values if the error is non-nil. The intended usage is:
a, b := grr.Log2(MyFunc(v))
func Log3 ¶
Log3 takes the given three values and error and returns the values if the error is nil, and logs the error and returns zero values if the error is non-nil. The intended usage is:
a, b, c := grr.Log3(MyFunc(v))
func Must ¶
func Must(err error)
Must takes the given error and panics if it is non-nil. The intended usage is:
grr.Must(MyFunc(v))
func Must1 ¶
Must1 takes the given value and error and returns the value if the error is nil, and panics if the error is non-nil. The intended usage is:
a := grr.Must1(MyFunc(v))
Types ¶
This section is empty.