-
Notifications
You must be signed in to change notification settings - Fork 8
/
errors.go
53 lines (44 loc) · 965 Bytes
/
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
package errors
type ErrorType struct {
t string
}
var (
ErrorTypeUnknown = ErrorType{"unknown"}
ErrorTypeAuthorization = ErrorType{"authorization"}
ErrorTypeIncorrectInput = ErrorType{"incorrect-input"}
)
type SlugError struct {
error string
slug string
errorType ErrorType
}
func (s SlugError) Error() string {
return s.error
}
func (s SlugError) Slug() string {
return s.slug
}
func (s SlugError) ErrorType() ErrorType {
return s.errorType
}
func NewSlugError(error string, slug string) SlugError {
return SlugError{
error: error,
slug: slug,
errorType: ErrorTypeUnknown,
}
}
func NewAuthorizationError(error string, slug string) SlugError {
return SlugError{
error: error,
slug: slug,
errorType: ErrorTypeAuthorization,
}
}
func NewIncorrectInputError(error string, slug string) SlugError {
return SlugError{
error: error,
slug: slug,
errorType: ErrorTypeIncorrectInput,
}
}