From 631b602b2839695c1b61fe5afddd4004754a5d07 Mon Sep 17 00:00:00 2001 From: hassieswift621 Date: Tue, 3 Dec 2019 11:48:42 +0000 Subject: [PATCH] Exported ErrAdjustBounds and ErrAdjustInvalid errors --- error.go | 15 +++++++-------- rest_client.go | 8 ++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/error.go b/error.go index c684745..9cb4dac 100644 --- a/error.go +++ b/error.go @@ -4,6 +4,13 @@ import ( "golang.org/x/xerrors" ) +// ErrAdjustBounds is returned by the adjust guild points and score methods if the amount to adjust is invalid. +var ErrAdjustBounds = xerrors.New("tatsumakigo: the amount to adjust must be between 0 and 50,000 (inclusive)") + +// ErrAdjustInvalid is returned by the adjust guild points and score methods if the amount to adjust +// for an action is invalid. +var ErrAdjustInvalid = xerrors.New("tatsumakigo: the amount to adjust for add and remove actions must be above 0") + func errorRequestFailed(err error) error { return xerrors.Errorf("tatsumakigo: failed to create request: %w", err) } @@ -19,11 +26,3 @@ func errorResponseFailed(err error) error { func errorParseFailed(err error) error { return xerrors.Errorf("tatsumakigo: failed to parse response: %w", err) } - -func errorAdjustInvalid() error { - return xerrors.New("tatsumakigo: the amount to adjust for add and remove actions must be above 0") -} - -func errorAdjustBounds() error { - return xerrors.New("tatsumakigo: the amount to adjust must be between 0 and 50,000 (inclusive)") -} diff --git a/rest_client.go b/rest_client.go index 15cfa5f..9cec763 100644 --- a/rest_client.go +++ b/rest_client.go @@ -31,12 +31,12 @@ func (rc *restClient) adjustGuildUserPoints(ctx context.Context, guildID string, action Action) (*GuildUserPoints, error) { // Check if amount is 0 and action is add or remove. if amount == 0 && (action == ActionAdd || action == ActionRemove) { - return nil, errorAdjustInvalid() + return nil, ErrAdjustInvalid } // Check if amount is between 0 and 50,000 (inclusive). if amount < 0 || amount > 50000 { - return nil, errorAdjustBounds() + return nil, ErrAdjustBounds } // Make request. @@ -63,12 +63,12 @@ func (rc *restClient) adjustGuildUserScore(ctx context.Context, guildID string, action Action) (*GuildUserScore, error) { // Check if amount is 0 and action is add or remove. if amount == 0 && (action == ActionAdd || action == ActionRemove) { - return nil, errorAdjustInvalid() + return nil, ErrAdjustInvalid } // Check if amount is between 0 and 50,000 (inclusive). if amount < 0 || amount > 50000 { - return nil, errorAdjustBounds() + return nil, ErrAdjustBounds } // Make request.