summaryrefslogtreecommitdiff
path: root/pkg/errorhandling
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/errorhandling')
-rw-r--r--pkg/errorhandling/errorhandling.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 9dc545ebb..9b1740006 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -33,6 +33,9 @@ func JoinErrors(errs []error) error {
// ErrorsToString converts the slice of errors into a slice of corresponding
// error messages.
func ErrorsToStrings(errs []error) []string {
+ if len(errs) == 0 {
+ return nil
+ }
strErrs := make([]string, len(errs))
for i := range errs {
strErrs[i] = errs[i].Error()
@@ -43,6 +46,9 @@ func ErrorsToStrings(errs []error) []string {
// StringsToErrors converts a slice of error messages into a slice of
// corresponding errors.
func StringsToErrors(strErrs []string) []error {
+ if len(strErrs) == 0 {
+ return nil
+ }
errs := make([]error, len(strErrs))
for i := range strErrs {
errs[i] = errors.New(strErrs[i])