-
Notifications
You must be signed in to change notification settings - Fork 158
/
crop_errors.go
153 lines (133 loc) · 4.63 KB
/
crop_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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package domain
const (
CropErrorInvalidArea = iota
CropErrorInvalidCropType
CropErrorInvalidCropStatus
// Crop move to area errors
CropMoveToAreaErrorInvalidSourceArea
CropMoveToAreaErrorSourceAreaNotFound
CropMoveToAreaErrorInvalidDestinationArea
CropMoveToAreaErrorDestinationAreaNotFound
CropMoveToAreaErrorInvalidQuantity
CropMoveToAreaErrorInvalidAreaRules
CropMoveToAreaErrorInvalidExistingSourceArea
CropMoveToAreaErrorCannotBeSame
CropMoveToAreaErrorInvalidExistingArea
// Crop harvest errors
CropHarvestErrorInvalidSourceArea
CropHarvestErrorSourceAreaNotFound
CropHarvestErrorInvalidQuantity
CropHarvestErrorNotEnoughQuantity
CropHarvestErrorInvalidHarvestType
// Crop dump errors
CropDumpErrorInvalidSourceArea
CropDumpErrorSourceAreaNotFound
CropDumpErrorInvalidQuantity
CropDumpErrorNotEnoughQuantity
// Crop water errors
CropWaterErrorInvalidWateringDate
CropWaterErrorInvalidSourceArea
CropWaterErrorSourceAreaNotFound
// Crop Batch ID errors
CropErrorInvalidBatchID
CropErrorBatchIDAlreadyCreated
// Crop Photo errros
CropErrorPhotoInvalidFilename
CropErrorPhotoInvalidMimeType
CropErrorPhotoInvalidSize
CropErrorPhotoInvalidDescription
CropContainerErrorInvalidType
CropContainerErrorInvalidQuantity
CropContainerErrorInvalidTrayCell
CropContainerErrorCropHasBeenMoved
CropMaterialErrorInvalidMaterial
CropMaterialErrorNotFound
CropNoteErrorInvalidContent
CropNoteErrorNotFound
)
// CropError is a custom error from Go built-in error
type CropError struct {
Code int
}
func (e CropError) Error() string {
switch e.Code {
case CropErrorInvalidArea:
return "Invalid area"
case CropErrorInvalidCropType:
return "Invalid crop type"
case CropErrorInvalidCropStatus:
return "Invalid crop status"
case CropErrorInvalidBatchID:
return "Invalid crop batch ID"
case CropErrorBatchIDAlreadyCreated:
return "Crop batch ID already created"
case CropMoveToAreaErrorInvalidSourceArea:
return "Crop source area is invalid"
case CropMoveToAreaErrorSourceAreaNotFound:
return "Crop source area not found"
case CropMoveToAreaErrorInvalidDestinationArea:
return "Crop destination area is invalid"
case CropMoveToAreaErrorDestinationAreaNotFound:
return "Crop destination not found"
case CropMoveToAreaErrorInvalidQuantity:
return "Invalid quantity. Make sure your quantity is not zero and enough to be moved"
case CropMoveToAreaErrorInvalidAreaRules:
return "Invalid move crop to area. Crop can only be moved from Seeding to Growing, Seeding to Seeding or Growing to Growing"
case CropMoveToAreaErrorInvalidExistingSourceArea:
return "Invalid existing source area"
case CropMoveToAreaErrorCannotBeSame:
return "Invalid move crop to area. Area source and destination cannot be same"
case CropMoveToAreaErrorInvalidExistingArea:
return "invalid existing area. Make sure your existing area is there"
case CropHarvestErrorInvalidSourceArea:
return "Invalid source area"
case CropHarvestErrorSourceAreaNotFound:
return "Source area not found"
case CropHarvestErrorInvalidQuantity:
return "Invalid quantity"
case CropHarvestErrorNotEnoughQuantity:
return "Not enough quantity"
case CropHarvestErrorInvalidHarvestType:
return "Invalid harvest type"
case CropDumpErrorInvalidSourceArea:
return "Invalid source area"
case CropDumpErrorSourceAreaNotFound:
return "Source area not found"
case CropDumpErrorInvalidQuantity:
return "Invalid quantity"
case CropDumpErrorNotEnoughQuantity:
return "Not enough current quantity to dump"
case CropWaterErrorInvalidWateringDate:
return "Invalid watering date"
case CropWaterErrorInvalidSourceArea:
return "Invalid source area"
case CropWaterErrorSourceAreaNotFound:
return "Source area not found"
case CropErrorPhotoInvalidFilename:
return "Invalid filename"
case CropErrorPhotoInvalidMimeType:
return "Invalid mime type"
case CropErrorPhotoInvalidSize:
return "Invalid size"
case CropErrorPhotoInvalidDescription:
return "Invalid description"
case CropContainerErrorInvalidType:
return "Invalid crop container type"
case CropContainerErrorInvalidQuantity:
return "Invalid crop container quantity"
case CropContainerErrorInvalidTrayCell:
return "Invalid crop container tray cell"
case CropContainerErrorCropHasBeenMoved:
return "Cannot change quantity and container because the crop batch has doing activity"
case CropMaterialErrorInvalidMaterial:
return "Invalid crop material"
case CropMaterialErrorNotFound:
return "Crop inventory material not found"
case CropNoteErrorInvalidContent:
return "Invalid crop note content"
case CropNoteErrorNotFound:
return "Crop note not found"
default:
return "Unrecognized Crop Error Code"
}
}