-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.go
99 lines (83 loc) · 2.9 KB
/
models.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
package errors
import "fmt"
//DocumentNotFoundError happens when a query should return a document but it's not found
type DocumentNotFoundError struct {
Collection string
ID string
}
//NewDocumentNotFoundError creates a new error
func NewDocumentNotFoundError(collection string, id string) *DocumentNotFoundError {
return &DocumentNotFoundError{
Collection: collection,
ID: id,
}
}
//Error string
func (err DocumentNotFoundError) Error() string {
return fmt.Sprintf("Document with id %s was not found in collection %s.", err.ID, err.Collection)
}
//ParameterIsRequiredError happens when a parameter for a given instance to be saved is required but is empty
type ParameterIsRequiredError struct {
Parameter string
Model string
}
//Error string
func (err ParameterIsRequiredError) Error() string {
return fmt.Sprintf("%s is required to create a new %s.", err.Parameter, err.Model)
}
//ItemNotFoundInGameError happens when a donation happens for an item that's not in the game
type ItemNotFoundInGameError struct {
ItemKey string
GameID string
}
//Error string
func (err ItemNotFoundInGameError) Error() string {
return fmt.Sprintf("Item %s was not found in game %s.", err.ItemKey, err.GameID)
}
//LimitOfItemsInDonationRequestReachedError happens when a donation happens for an item that's not in the game
type LimitOfItemsInDonationRequestReachedError struct {
GameID string
DonationRequestID string
ItemKey string
Amount int
}
//Error string
func (err LimitOfItemsInDonationRequestReachedError) Error() string {
return "This donation request can't accept this donation."
}
//LimitOfItemsPerPlayerInDonationRequestReachedError happens when a donation happens for an item that's not in the game
type LimitOfItemsPerPlayerInDonationRequestReachedError struct {
GameID string
DonationRequestID string
ItemKey string
Amount int
Player string
CurrentDonationCount int
}
//Error string
func (err LimitOfItemsPerPlayerInDonationRequestReachedError) Error() string {
return "This donation request can't accept any more donations from this player."
}
//DonationRequestCooldownViolatedError happens when a donation request
//is created in less than <cooldown> hours after last one
type DonationRequestCooldownViolatedError struct {
GameID string
ItemKey string
Time int64
}
//Error string
func (err DonationRequestCooldownViolatedError) Error() string {
return "This player can't create a new donation request so soon."
}
//DonationCooldownViolatedError happens when a donation request
//is created in less than <cooldown> hours after last one
type DonationCooldownViolatedError struct {
GameID string
PlayerID string
TotalWeightForPeriod int
MaxWeightForPerior int
}
//Error string
func (err DonationCooldownViolatedError) Error() string {
return "This player can't donate so soon."
}