diff --git a/README.md b/README.md index b421f34..c42a589 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Go Errors Detail -[![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) diff --git a/errors/errors.go b/errors/errors.go index e168d71..e0ea38b 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -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 @@ -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 } diff --git a/errors/errors_test.go b/errors/errors_test.go index c4a125a..9aece79 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -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("")) }