Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cataldo committed Feb 7, 2024
1 parent 4ac5606 commit 12f8506
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
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.7-vividgreen.svg)](https://github.com/GabrielHCataldo/go-errors/releases/tag/v1.1.7)
[![Project status](https://img.shields.io/badge/version-v1.1.8-vividgreen.svg)](https://github.com/GabrielHCataldo/go-errors/releases/tag/v1.1.8)
[![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
4 changes: 3 additions & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func NotContains(err, target error) bool {

// Error print the error as a string, genetic implementation of error in go
func (e *ErrorDetail) Error() string {
return fmt.Sprint("[CAUSE]: ", e.GetCause(), " [STACK]: \n", e.debugStack)
return fmt.Sprint("[CAUSE]: ", e.GetCause(), " [STACK]: ", e.debugStack)
}

// PrintStackTrace print red message with detail error and debug stack
Expand Down Expand Up @@ -189,5 +189,7 @@ func printMessage(v ...any) string {
msg := helper.Sprintln(v...)
msg = strings.ReplaceAll(msg, "[STACK]", "")
msg = strings.ReplaceAll(msg, "[CAUSE]", "")
re := regexp.MustCompile(`\r?\n`)
msg = re.ReplaceAllString(msg, " ")
return msg
}
2 changes: 1 addition & 1 deletion errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +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("test error detail", New("sub error message\ntest\ttes2")))
logger.Info("err:", New(""))
}

Expand Down

0 comments on commit 12f8506

Please sign in to comment.