forked from leg100/otf
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherrors.go
More file actions
91 lines (68 loc) · 2.48 KB
/
errors.go
File metadata and controls
91 lines (68 loc) · 2.48 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package internal
import (
"errors"
"fmt"
"github.com/jackc/pgx/v5/pgconn"
)
// Generic errors
var (
// ErrAccessNotPermitted is returned when an authorization check fails.
ErrAccessNotPermitted = errors.New("access to the resource is not permitted")
// ErrUnauthorized is returned when a receiving a 401.
ErrUnauthorized = errors.New("unauthorized")
// ErrResourceNotFound is returned when a receiving a 404.
ErrResourceNotFound = errors.New("resource not found")
// ErrResourceAlreadyExists is returned when attempting to create a resource
// that already exists.
ErrResourceAlreadyExists = errors.New("resource already exists")
// ErrRequiredName is returned when a name option is not present.
ErrRequiredName = errors.New("name is required")
// ErrInvalidName is returned when the name option has invalid value.
ErrInvalidName = errors.New("invalid value for name")
// ErrEmptyValue is returned when a value is set to an empty string
ErrEmptyValue = errors.New("value cannot be empty")
// ErrTimeout is returned when a request exceeds a timeout.
ErrTimeout = errors.New("request timed out")
// ErrConflict is returned when a requests attempts to either create a
// resource with an identifier that already exists, or if an invalid state
// transition is attempted
ErrConflict = errors.New("resource conflict detected")
)
// Resource Errors
var (
// ErrInvalidTerraformVersion is returned when a terraform version string is
// not a semantic version string (major.minor.patch).
ErrInvalidTerraformVersion = errors.New("invalid terraform version")
// ErrRequiredOrg is returned when the organization option is not present
ErrRequiredOrg = errors.New("organization is required")
ErrStatusTimestampNotFound = errors.New("corresponding status timestamp not found")
ErrInvalidRepo = errors.New("repository path is invalid")
)
type (
HTTPError struct {
Code int
Message string
}
// MissingParameterError occurs when the caller has failed to provide a
// required parameter
MissingParameterError struct {
Parameter string
}
// ForeignKeyError occurs when there is a foreign key violation.
ForeignKeyError struct {
*pgconn.PgError
}
InvalidParameterError string
)
func (e InvalidParameterError) Error() string {
return string(e)
}
func (e *HTTPError) Error() string {
return e.Message
}
func (e *MissingParameterError) Error() string {
return fmt.Sprintf("required parameter missing: %s", e.Parameter)
}
func (e *ForeignKeyError) Error() string {
return e.Detail
}