Welcome to mirror list, hosted at ThFree Co, Russian Federation.

errors.go « parser « lsif_transformer « internal « workhorse - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1040a7894138574e7e2fa5fe7bc7dd113193901f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package parser

import (
	"errors"
	"strings"
)

func combineErrors(errsOrNil ...error) error {
	var errs []error
	for _, err := range errsOrNil {
		if err != nil {
			errs = append(errs, err)
		}
	}

	if len(errs) == 0 {
		return nil
	}

	if len(errs) == 1 {
		return errs[0]
	}

	var msgs []string
	for _, err := range errs {
		msgs = append(msgs, err.Error())
	}

	return errors.New(strings.Join(msgs, "\n"))
}