diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index d6bcb13..5cb2eb4 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -17,4 +17,4 @@ jobs: with: release-branches: '["main"]' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT }} diff --git a/.golangci.yaml b/.golangci.yaml index 6a90e2a..54a6514 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -192,7 +192,6 @@ linters: - durationcheck # checks for two durations multiplied together - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - execinquery # checks query string in Query function which reads your Go src files and warning it finds - exhaustive # checks exhaustiveness of enum switch statements - exportloopref # checks for pointers to enclosing loop variables - forbidigo # forbids identifiers @@ -267,6 +266,7 @@ linters: #- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages #- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) #- dupword # [useless without config] checks for duplicate words in the source code + #- execinquery # checks query string in Query function which reads your Go src files and warning it finds #- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted #- forcetypeassert # [replaced by errcheck] finds forced type assertions #- goerr113 # [too strict] checks the errors handling expressions diff --git a/README.md b/README.md index f1e39aa..2f1e995 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # Oops, Errors +[![Go Reference](https://pkg.go.dev/badge/github.com/jesse0michael/oops.svg)](https://pkg.go.dev/github.com/jesse0michael/oops) + Error handling for adding attributes and source location to errors when logging them. Inspired by [https://github.com/samber/oops](https://github.com/samber/oops) with a minimal API. -Works with [log/slog](https://pkg.go.dev/log/slog) through a [LogerValue]() that decorates the logged error attribute with the attributes and source location to any `oops.Error`. +Works with [log/slog](https://pkg.go.dev/log/slog) through a [LogValue](https://pkg.go.dev/log/slog#LogValuer) that decorates the logged error attribute with the attributes and source location to any `oops.Error`. ## Example @@ -38,21 +40,23 @@ func main() { } ``` ->{ -> "time":"2025-02-01T21:59:54.959869-07:00", -> "level":"ERROR", -> "msg":"error", -> "err":{ -> "err":"process not found", -> "id":"oops", -> "method":"Run", -> "source":{ -> "file":"#####/github.com/jesse0michael/oops/README.md", -> "function":"github.com/jesse0michael/oops.process", -> "line":30 -> } -> } ->} +```json +{ + "time":"2025-02-01T21:59:54.959869-07:00", + "level":"ERROR", + "msg":"error", + "err":{ + "err":"process not found", + "id":"oops", + "method":"Run", + "source":{ + "file":"#####/github.com/jesse0michael/oops/README.md", + "function":"github.com/jesse0michael/oops.process", + "line":30 + } + } +} +``` This example highlights some of the different ways to create and decorate errors by dropping in the oops package. Create a new error with `oops.New` or wrap an existing error with `oops.Wrap` or use `oops.Errorf` to format an error message.