checkpoint: more static error types
This commit is contained in:
parent
48c8579de6
commit
646eaeac23
3 changed files with 21 additions and 6 deletions
|
@ -1,7 +1,6 @@
|
|||
package executor
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
||||
|
@ -199,7 +198,7 @@ func (a *AddExecutor) addBoostToStatus(gtsClient *client.Client) error {
|
|||
|
||||
func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
||||
if a.votes.Empty() {
|
||||
return errors.New("please use --" + flagVote + " to make a choice in this poll")
|
||||
return NoVotesError{}
|
||||
}
|
||||
|
||||
status, err := gtsClient.GetStatus(a.statusID)
|
||||
|
@ -208,7 +207,7 @@ func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
|||
}
|
||||
|
||||
if status.Poll == nil {
|
||||
return errors.New("this status does not have a poll")
|
||||
return NoPollInStatusError{}
|
||||
}
|
||||
|
||||
if status.Poll.Expired {
|
||||
|
@ -225,7 +224,7 @@ func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
|||
}
|
||||
|
||||
if status.Account.ID == myAccountID {
|
||||
return errors.New("you cannot vote in your own poll")
|
||||
return PollOwnerVoteError{}
|
||||
}
|
||||
|
||||
pollID := status.Poll.ID
|
||||
|
|
|
@ -104,6 +104,24 @@ func (e NoPollOptionError) Error() string {
|
|||
" flag to add options to the poll"
|
||||
}
|
||||
|
||||
type NoVotesError struct{}
|
||||
|
||||
func (e NoVotesError) Error() string {
|
||||
return "no votes were made, please add your vote(s) using the --vote flag"
|
||||
}
|
||||
|
||||
type NoPollInStatusError struct{}
|
||||
|
||||
func (e NoPollInStatusError) Error() string {
|
||||
return "this status does not have a poll"
|
||||
}
|
||||
|
||||
type PollOwnerVoteError struct{}
|
||||
|
||||
func (e PollOwnerVoteError) Error() string {
|
||||
return "you cannot vote in your own poll"
|
||||
}
|
||||
|
||||
type NotFollowingError struct {
|
||||
Account string
|
||||
}
|
||||
|
|
|
@ -8,11 +8,9 @@ const (
|
|||
flagInstance = "instance"
|
||||
flagListID = "list-id"
|
||||
flagListTitle = "list-title"
|
||||
flagPollID = "poll-id"
|
||||
flagPollOption = "poll-option"
|
||||
flagStatusID = "status-id"
|
||||
flagTag = "tag"
|
||||
flagTo = "to"
|
||||
flagType = "type"
|
||||
flagVote = "vote"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue