-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
56 lines (47 loc) · 1.23 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
53
54
55
56
package filesystem
import (
"errors"
"fmt"
"strings"
)
var (
// ErrorInvalidGameInfo
ErrorInvalidGameInfo = errors.New("gameinfo keyvalues do not match expected specification")
)
// FileNotFoundError
type FileNotFoundError struct {
fileName string
}
// Error
func (err FileNotFoundError) Error() string {
return fmt.Sprintf("%s not found in filesystem", err.fileName)
}
// NewFileNotFoundError
func NewFileNotFoundError(filename string) *FileNotFoundError {
return &FileNotFoundError{
fileName: filename,
}
}
// InvalidResourcePathCollectionError
type InvalidResourcePathCollectionError struct {
paths []string
}
// Error will return a list of paths that could not be added.
// This list is a pipe-separated(|) string
func (err InvalidResourcePathCollectionError) Error() string {
msg := ""
for _,p := range err.paths {
msg += p + "|"
}
return strings.Trim(msg, "|")
}
// AddPath adds a new path to this error colleciton
func (err InvalidResourcePathCollectionError) AddPath(path string) {
err.paths = append(err.paths, path)
}
// NewInvalidResourcePathCollectionError
func NewInvalidResourcePathCollectionError() *InvalidResourcePathCollectionError {
return &InvalidResourcePathCollectionError{
paths: make([]string, 0),
}
}