new errors

This commit is contained in:
Dan Anglin 2024-06-12 17:45:32 +01:00
parent a5e1c4ac79
commit cea9328be9
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
2 changed files with 14 additions and 2 deletions

View file

@ -265,11 +265,11 @@ func (a *AddExecutor) addVoteToPoll(gtsClient *client.Client) error {
}
if poll.Expired {
return errors.New("this poll has expired")
return ExpiredPollError{}
}
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 {

View file

@ -66,3 +66,15 @@ type UnknownCommandError struct {
func (e UnknownCommandError) Error() string {
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"
}