Documentation ¶
Overview ¶
Example (CustomError_LogValue) ¶
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{ ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { if a.Key == "time" || a.Key == "level" { return slog.Attr{} } return a }, }))) slog.Info("test message", slog.Any("error", New("test").With("test key", "test value")))
Output: msg="test message" error.message=test "error.test key"="test value"
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func As ¶
Example ¶
if _, err := os.Open("non-existing"); err != nil { var pathError *fs.PathError if As(err, &pathError) { fmt.Println("Failed at path:", pathError.Path) } else { fmt.Println(err) } }
Output: Failed at path: non-existing
Types ¶
type CustomError ¶
type CustomError interface { error With(key string, value interface{}) CustomError WithData(map[string]any) CustomError Cause() error Unwrap() error }
func New ¶
func New(message string) CustomError
func Wrap ¶
func Wrap(err error) CustomError
func WrapDepth ¶
func WrapDepth(err error, depth int) CustomError
func WrapWithData ¶
func WrapWithData(err error, data map[string]any) CustomError
Click to show internal directories.
Click to hide internal directories.