samber / samber/oops

Key values specified using `With` isn't being shown, when assertion fails

Open
#114 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
990
Forks
45
Avg merge
5d 9h
Merged PRs (30d)
5

Description

err := errors.New("HELLO")
oops.With("error", err).Assertf((err == nil), "Failed connecting to Elasticsearch")

outputs :

panic: Failed connecting to Elasticsearch

goroutine 1 [running]:
github.com/samber/oops.OopsErrorBuilder.Assertf(...)
        /tmp/gopath2180193886/pkg/mod/github.com/samber/oops@v1.21.0/builder.go:306
github.com/samber/oops.Assertf(_, {_, _}, {_, _, _})
        /tmp/gopath2180193886/pkg/mod/github.com/samber/oops@v1.21.0/oops.go:70 +0x1d8
main.main()
        /tmp/sandbox2172285662/prog.go:11 +0x33

Can we have a way, so that key values specified using With also get logged?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OopsErrorBuilder.Assertf and the oops.Assertf call shown in the example, then trace how values supplied through With are handled when the assertion fails. Done means the failure output includes the key and error value from With("error", err), while preserving the existing assertion message and stack trace.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.