rs / zerolog

Zero Allocation JSON Logger
MIT License
10.62k stars 572 forks source link

(#470) Localize github.com/pkg/errors #471

Closed vaguecoder closed 8 months ago

vaguecoder commented 2 years ago

Motivation

Issue #470 reported by @skormos

Changes

Adds new internal package errors with test coverage.

Summary

Localizes following functions (and required types and methods) from github.com/pkg/errors as it is no longer being maintained.

New(message string) error
Wrap(err error, message string) error

Related Issues

Closes #470 Helps in #462

rs commented 2 years ago

After this change, as we do not expose the errors.Wrap, how are users supposed to use this feature?

vaguecoder commented 2 years ago

@rs I totally missed that Wrap is required by users. Can it be included in the same package as MarshalStack? I understand that it means extending pkgerrors layer.

rs commented 2 years ago

Reading the change I'm not really fan of the resulting API. I wonder if we could keep backward compat (when getting a wrapped error) and at the same time, auto-wrap an error when Stack is present and Err is called. This way we do not expose a new API.