-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
52 lines (39 loc) · 1.38 KB
/
errors.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"errors"
"fmt"
"sort"
"strings"
"github.com/yoanm/go-github-tf/core"
)
var (
errDuringWorkspaceLoading = errors.New("error during workspace loading")
errDuringConfigsLoading = errors.New("error during configs loading")
errDuringTemplateLoading = errors.New("error during templates loading")
errInputDirectoryDoesntExist = errors.New("input directory doesn't exist")
errRepositoryAlreadyImported = errors.New("repository already imported")
)
func workspaceLoadingError(errList []error) error {
const separator = "\n"
return fmt.Errorf("%w:%s%w", errDuringWorkspaceLoading, separator, core.JoinErrors(errList, separator))
}
func configDirectoryLoadingError(errList []error) error {
const separator = "\n\t - "
return fmt.Errorf("%w:%s%w", errDuringConfigsLoading, separator, core.JoinErrors(errList, separator))
}
func templateLoadingError(errList []error) error {
const separator = "\n\t - "
return fmt.Errorf("%w:%s%w", errDuringTemplateLoading, separator, core.JoinErrors(errList, separator))
}
func inputDirectoryDoesntExistError(path string) error {
return fmt.Errorf("%w: %s", errInputDirectoryDoesntExist, path)
}
func alreadyImportedRepositoryError(repoName string, filepathList []string) error {
sort.Strings(filepathList)
return fmt.Errorf(
"%w: %q imported by %s",
errRepositoryAlreadyImported,
repoName,
strings.Join(filepathList, ", "),
)
}