You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/19 11:02:11 UTC
[plc4x] 02/05: fix(plc4go/spi): multierror only returns a error if it has an error
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit ddda58bb3e4b9d0d8a188a1b534d64a17c4a37d0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jun 19 11:58:33 2023 +0200
fix(plc4go/spi): multierror only returns a error if it has an error
---
plc4go/spi/utils/Errors.go | 3 +++
plc4go/spi/utils/Errors_test.go | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/plc4go/spi/utils/Errors.go b/plc4go/spi/utils/Errors.go
index 697dffaeee..ec7ff5e4bd 100644
--- a/plc4go/spi/utils/Errors.go
+++ b/plc4go/spi/utils/Errors.go
@@ -39,6 +39,9 @@ type MultiError struct {
}
func (m MultiError) Error() string {
+ if m.MainError == nil && len(m.Errors) == 0 {
+ return ""
+ }
mainErrorText := "Child errors:\n"
if m.MainError != nil {
mainErrorText = fmt.Sprintf("Main Error: %v\nChild errors:\n", m.MainError)
diff --git a/plc4go/spi/utils/Errors_test.go b/plc4go/spi/utils/Errors_test.go
index 5fa3d28f0f..cd4a2e7bc8 100644
--- a/plc4go/spi/utils/Errors_test.go
+++ b/plc4go/spi/utils/Errors_test.go
@@ -38,7 +38,7 @@ func TestMultiError_Error(t *testing.T) {
}{
{
name: "empty multi error",
- want: "Child errors:\nNo errors",
+ want: "",
},
{
name: "some error",