Releases: muonsoft/errors
Releases · muonsoft/errors
v0.5.0
What's Changed
Native log/slog integration. This release replaces the custom field system with slog.Attr as the core type for error attributes. The logrus adapter has been removed.
Highlights
slog.Attreverywhere — Useslog.String(),slog.Int(),slog.Group(), etc. directly inerrors.Wrap()anderrors.Errorf()alongside existing options.errors.Attrs(err)— Extract all attributes from an error chain for custom logging.errors.Log(ctx, logger, err)— Log an error at Error level with attributes and stack trace.errors.LogLevel(ctx, logger, level, err)— Same as above with an explicit level (Debug, Info, Warn, Error).- New attribute options —
Int64,Uint64,Float64,Any.Valueis deprecated in favor ofAny. - Grouped attributes — Full support for
slog.Groupin errors, JSON marshaling, and%+vformatting (dot notation). slog.LogValuer— Errors implementLogValuerfor native slog handling.
Breaking changes
- Custom
Fieldtypes andFieldLoggerare removed; useslog.Attrand*slog.Logger. LoggableErrornow requiresAttrs() []slog.Attrinstead ofLogFields(FieldLogger).errors.Log(err, logger)replaced byerrors.Log(ctx, logger, err).- Package requires Go 1.21+.
- logrus adapter removed — see migration guide for a small custom adapter if needed.
Migration
If you are upgrading from v0.4.x, read the Migration Guide for step-by-step instructions and before/after examples.
Full Changelog: v0.4.1...v0.5.0
v0.4.1
v0.4.0
errors.Join()function addederrors.Stringer()option added- adopt errors wrapping behaviour to be consistent with multi errors introduced in go v1.20
- minimal go version fixed to v1.20
v0.3.0
errors.IsOfType[T any](err error)function added- logrus adapter improvements
v0.2.0
errors.As()function based on typed parameters- fixes for logrus adapter
- minimal required Go version is v1.18
v0.1.0
Initial version