Skip to content

Commit

Permalink
verbose: nil behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcase committed Apr 8, 2023
1 parent fa2e7dd commit 836e6c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions verbose.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func (ve *VerboseError) Unwrap() error {

// Verbose wraps an error making its string output verbose ("%+v").
func Verbose(err error) error {
if err == nil {
return nil
}

return &VerboseError{
Err: err,
}
Expand Down
2 changes: 2 additions & 0 deletions verbose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ func TestVerbose(t *testing.T) {

vflines := len(strings.Split(fmt.Sprintf("%v", verr), "\n"))
require.Greater(t, vflines, 1)

require.Nil(t, oops.Verbose(nil))
}

0 comments on commit 836e6c3

Please sign in to comment.