-
Notifications
You must be signed in to change notification settings - Fork 40
/
fileErrors.go
69 lines (58 loc) · 1.77 KB
/
fileErrors.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
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
import (
"errors"
"fmt"
)
var (
// ErrFileTooLong is the error given when a file exceeds the maximum possible length
ErrFileTooLong = errors.New("file exceeds maximum possible number of lines")
)
// TagWrongLengthErr is the error given when a Tag is the wrong length
type TagWrongLengthErr struct {
Message string
TagLength int
Length int
}
// NewTagWrongLengthErr creates a new error of the TagWrongLengthErr type
func NewTagWrongLengthErr(tagLength, length int) TagWrongLengthErr {
return TagWrongLengthErr{
Message: fmt.Sprintf("must be %d characters and found %d", tagLength, length),
TagLength: tagLength,
Length: length,
}
}
// NewTagMinLengthErr creates a new error of the TagWrongLengthErr type
func NewTagMinLengthErr(tagLength, length int) TagWrongLengthErr {
return TagWrongLengthErr{
Message: fmt.Sprintf("must be minimum %d characters and found %d", tagLength, length),
TagLength: tagLength,
Length: length,
}
}
// NewTagMaxLengthErr creates a new error of the TagWrongLengthErr type
func NewTagMaxLengthErr(err error) TagWrongLengthErr {
return TagWrongLengthErr{
Message: fmt.Sprintf("invalid information in a segment: %v", err),
}
}
func (e TagWrongLengthErr) Error() string {
return e.Message
}
// ErrInvalidTag is the error given when a tag is invalid
type ErrInvalidTag struct {
Message string
Type string
}
// NewErrInvalidTag creates a new error of the ErrInvalidTag type
func NewErrInvalidTag(tag string) ErrInvalidTag {
return ErrInvalidTag{
Message: fmt.Sprintf("%s is an invalid tag", tag),
Type: tag,
}
}
func (e ErrInvalidTag) Error() string {
return e.Message
}