/
helpers.go
102 lines (92 loc) · 2.21 KB
/
helpers.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package errorz
func NewNotFound() *ApiError {
return &ApiError{
Code: NotFoundCode,
Message: NotFoundMessage,
Status: NotFoundStatus,
}
}
func NewUnhandled(cause error) *ApiError {
return &ApiError{
Code: UnhandledCode,
Message: UnhandledMessage,
Status: UnhandledStatus,
Cause: cause,
}
}
func NewEntityCanNotBeDeleted() *ApiError {
return &ApiError{
Code: EntityCanNotBeDeletedCode,
Message: EntityCanNotBeDeletedMessage,
Status: EntityCanNotBeDeletedStatus,
}
}
func NewEntityCanNotBeDeletedFrom(err error) *ApiError {
return &ApiError{
Code: EntityCanNotBeDeletedCode,
Message: EntityCanNotBeDeletedMessage,
Status: EntityCanNotBeDeletedStatus,
Cause: err,
AppendCause: true,
}
}
func NewEntityCanNotBeUpdatedFrom(err error) *ApiError {
return &ApiError{
Code: EntityCanNotBeUpdatedCode,
Message: EntityCanNotBeUpdatedMessage,
Status: EntityCanNotBeUpdatedStatus,
Cause: err,
AppendCause: true,
}
}
func NewFieldApiError(fieldError *FieldError) *ApiError {
return &ApiError{
Code: InvalidFieldCode,
Message: InvalidFieldMessage,
Status: InvalidFieldStatus,
Cause: fieldError,
AppendCause: true,
}
}
func NewCouldNotValidate(err error) *ApiError {
return &ApiError{
Code: CouldNotValidateCode,
Message: CouldNotValidateMessage,
Status: CouldNotValidateStatus,
Cause: err,
}
}
func NewUnauthorized() *ApiError {
return &ApiError{
Code: UnauthorizedCode,
Message: UnauthorizedMessage,
Status: UnauthorizedStatus,
}
}
func NewInvalidFilter(cause error) *ApiError {
return &ApiError{
Code: InvalidFilterCode,
Message: InvalidFilterMessage,
Status: InvalidFilterStatus,
Cause: cause,
AppendCause: true,
}
}
func NewInvalidPagination(err error) *ApiError {
return &ApiError{
Code: InvalidPaginationCode,
Message: InvalidPaginationMessage,
Status: InvalidPaginationStatus,
Cause: err,
AppendCause: true,
}
}
func NewInvalidSort(err error) *ApiError {
return &ApiError{
Code: InvalidSortCode,
Message: InvalidSortMessage,
Status: InvalidSortStatus,
Cause: err,
AppendCause: true,
}
}