new errors
This commit is contained in:
parent
a5e1c4ac79
commit
cea9328be9
2 changed files with 14 additions and 2 deletions
|
@ -265,11 +265,11 @@ func (a *AddExecutor) addVoteToPoll(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if poll.Expired {
|
if poll.Expired {
|
||||||
return errors.New("this poll has expired")
|
return ExpiredPollError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !poll.Multiple && len(a.choices) > 1 {
|
if !poll.Multiple && len(a.choices) > 1 {
|
||||||
return errors.New("this poll does not allow multiple choices")
|
return MultipleChoiceError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gtsClient.VoteInPoll(a.pollID, []int(a.choices)); err != nil {
|
if err := gtsClient.VoteInPoll(a.pollID, []int(a.choices)); err != nil {
|
||||||
|
|
|
@ -66,3 +66,15 @@ type UnknownCommandError struct {
|
||||||
func (e UnknownCommandError) Error() string {
|
func (e UnknownCommandError) Error() string {
|
||||||
return "unknown command '" + e.Command + "'"
|
return "unknown command '" + e.Command + "'"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExpiredPollError struct{}
|
||||||
|
|
||||||
|
func (e ExpiredPollError) Error() string {
|
||||||
|
return "this poll has expired"
|
||||||
|
}
|
||||||
|
|
||||||
|
type MultipleChoiceError struct{}
|
||||||
|
|
||||||
|
func (e MultipleChoiceError) Error() string {
|
||||||
|
return "this poll does not allow multiple choices"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue