Skip to content

Commit

Permalink
Bug fix for detail error on detail error, if one of the parameters is…
Browse files Browse the repository at this point in the history
… the detail error itself, we only get the same message.
  • Loading branch information
Gabriel Cataldo committed Feb 7, 2024
1 parent f9bafb8 commit 5cd1fc5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Go Errors Detail
<!--suppress ALL -->
<img align="right" src="gopher-debug.png" alt="">

[![Project status](https://img.shields.io/badge/version-v1.1.5-vividgreen.svg)](https://github.com/GabrielHCataldo/go-errors/releases/tag/v1.1.5)
[![Project status](https://img.shields.io/badge/version-v1.1.6-vividgreen.svg)](https://github.com/GabrielHCataldo/go-errors/releases/tag/v1.1.6)
[![Go Report Card](https://goreportcard.com/badge/github.com/GabrielHCataldo/go-errors)](https://goreportcard.com/report/github.com/GabrielHCataldo/go-errors)
[![Coverage Status](https://coveralls.io/repos/GabrielHCataldo/go-errors/badge.svg?branch=main&service=github)](https://coveralls.io/github/GabrielHCataldo/go-errors?branch=main)
[![Open Source Helpers](https://www.codetriage.com/gabrielhcataldo/go-errors/badges/users.svg)](https://www.codetriage.com/gabrielhcataldo/go-errors)
Expand Down
7 changes: 7 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ func Details(err error) *ErrorDetail {
}

func printMessage(v ...any) string {
for i, iv := range v {
ivError, ok := iv.(error)
if helper.IsError(iv) && ok {
errDetail := Details(ivError)
v[i] = errDetail.message
}
}
msg := helper.Sprintln(v...)
msg = strings.ReplaceAll(msg, "[STACK]", "")
msg = strings.ReplaceAll(msg, "[CAUSE]", "")
Expand Down
1 change: 1 addition & 0 deletions errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func TestNew(t *testing.T) {
logger.Info("err:", New("test error detail"))
logger.Info("err:", New("test error detail", New("sub error message")))
logger.Info("err:", New(""))
}

Expand Down

0 comments on commit 5cd1fc5

Please sign in to comment.