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
|
package executor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeflow.dananglin.me.uk/apollo/enbas/internal/client"
|
"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 {
|
func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
||||||
if a.votes.Empty() {
|
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)
|
status, err := gtsClient.GetStatus(a.statusID)
|
||||||
|
@ -208,7 +207,7 @@ func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Poll == nil {
|
if status.Poll == nil {
|
||||||
return errors.New("this status does not have a poll")
|
return NoPollInStatusError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Poll.Expired {
|
if status.Poll.Expired {
|
||||||
|
@ -225,7 +224,7 @@ func (a *AddExecutor) addVoteToStatus(gtsClient *client.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Account.ID == myAccountID {
|
if status.Account.ID == myAccountID {
|
||||||
return errors.New("you cannot vote in your own poll")
|
return PollOwnerVoteError{}
|
||||||
}
|
}
|
||||||
|
|
||||||
pollID := status.Poll.ID
|
pollID := status.Poll.ID
|
||||||
|
|
|
@ -104,6 +104,24 @@ func (e NoPollOptionError) Error() string {
|
||||||
" flag to add options to the poll"
|
" 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 {
|
type NotFollowingError struct {
|
||||||
Account string
|
Account string
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,9 @@ const (
|
||||||
flagInstance = "instance"
|
flagInstance = "instance"
|
||||||
flagListID = "list-id"
|
flagListID = "list-id"
|
||||||
flagListTitle = "list-title"
|
flagListTitle = "list-title"
|
||||||
flagPollID = "poll-id"
|
|
||||||
flagPollOption = "poll-option"
|
flagPollOption = "poll-option"
|
||||||
flagStatusID = "status-id"
|
flagStatusID = "status-id"
|
||||||
flagTag = "tag"
|
flagTag = "tag"
|
||||||
flagTo = "to"
|
flagTo = "to"
|
||||||
flagType = "type"
|
flagType = "type"
|
||||||
flagVote = "vote"
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue