/
errors.go
67 lines (54 loc) · 1.63 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
57
58
59
60
61
62
63
64
65
66
67
package issues
import (
// Stdlib
"fmt"
// Vendor
"github.com/google/go-github/github"
)
// ErrUnknownReviewIssueType is returned when the issue type cannot be recognized.
type ErrUnknownReviewIssueType struct {
issue *github.Issue
}
func (err *ErrUnknownReviewIssueType) Error() string {
return fmt.Sprintf("failed to detect review issue type for %v", *err.issue.HTMLURL)
}
// ErrInvalidTitle is returned when the issue title is malformed.
type ErrInvalidTitle struct {
issue *github.Issue
}
func (err *ErrInvalidTitle) Error() string {
return fmt.Sprintf("issue %v: invalid issue title", *err.issue.HTMLURL)
}
// ErrInvalidBody is returned when the issue body is malformed.
type ErrInvalidBody struct {
issue *github.Issue
lineNo int
line string
}
func (err *ErrInvalidBody) Error() string {
var prefix string
if err.issue != nil {
prefix = fmt.Sprintf("issue %v: ", *err.issue.HTMLURL)
}
return fmt.Sprintf(`%vfailed to parse issue body [lineNo=%v, line="%v"]`,
prefix, err.lineNo, err.line)
}
// ErrTagNotFound is returned when there is a SalsaFlow metadata tag missing in the body.
type ErrTagNotFound struct {
issue *github.Issue
tag string
}
func (err *ErrTagNotFound) Error() string {
return fmt.Sprintf("issue %v: tag not found: %v", *err.issue.HTMLURL, err.tag)
}
// ErrScanning is returned from bodyScanner.ReadLine when the internal scanner returns an error.
type ErrScanning struct {
issue *github.Issue
lineNo int
line string
err error
}
func (err *ErrScanning) Error() string {
return fmt.Sprintf(`issue %v: scanner error: %v [lineNo=%v, line="%v"]`,
*err.issue.HTMLURL, err.err, err.lineNo, err.line)
}