aboutsummaryrefslogtreecommitdiff
path: root/user/anime
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-03-06 00:51:36 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-03-06 00:51:36 +0530
commitb6f42d806d0e0f5e59c7615cd1558e75c5b314f1 (patch)
treec9c014759f62c44520be305a60546d08140876f4 /user/anime
parent95b8ab702708538ccaf26efd141b448148ac6d6d (diff)
Exported all the errors so programs using this library can customize error messages.
Diffstat (limited to 'user/anime')
-rw-r--r--user/anime/animelist.go5
-rw-r--r--user/anime/update_animelist.go17
2 files changed, 10 insertions, 12 deletions
diff --git a/user/anime/animelist.go b/user/anime/animelist.go
index f6d9965..2840df3 100644
--- a/user/anime/animelist.go
+++ b/user/anime/animelist.go
@@ -20,7 +20,6 @@ import (
"encoding/json"
"strconv"
"fmt"
- "errors"
a "github.com/MikunoNaka/MAL2Go/anime"
e "github.com/MikunoNaka/MAL2Go/errhandlers"
u "github.com/MikunoNaka/MAL2Go/util"
@@ -57,12 +56,12 @@ func (c Client) GetAnimeList(user, status, sort string, limit, offset int, field
// checks if valid sort is specified
if !e.IsValidListSort(sort) {
- return userAnimeList, errors.New(fmt.Sprintf("GetAnimeList: Invalid sort specified: \"%s\"", sort))
+ return userAnimeList, e.InvalidSortError
}
// checks if valid status is specified
if status != "" && !e.IsValidListStatus(status) {
- return userAnimeList, errors.New(fmt.Sprintf("GetAnimeList: Invalid status specified: \"%s\"", status))
+ return userAnimeList, e.InvalidStatusError
}
// get own list if user not specified
diff --git a/user/anime/update_animelist.go b/user/anime/update_animelist.go
index 8371691..780f079 100644
--- a/user/anime/update_animelist.go
+++ b/user/anime/update_animelist.go
@@ -17,7 +17,6 @@ package anime
import (
e "github.com/MikunoNaka/MAL2Go/errhandlers"
- "errors"
"fmt"
"net/url"
"strconv"
@@ -34,7 +33,7 @@ func (c Client)SetStatus(id int, status string) (serverResponse, error) {
// checks if specified list status is valid
if !e.IsValidListStatus(status) {
- return serverResponse{}, errors.New(fmt.Sprintf("SetStatus: Invalid list status: \"%s\"", status))
+ return serverResponse{}, e.InvalidStatusError
}
// data to be sent to the server
@@ -75,7 +74,7 @@ func (c Client)SetScore(id int, score int) (serverResponse, error) {
// checks if specified score is valid
if !e.IsValidScore(score) {
- return serverResponse{}, errors.New(fmt.Sprintf("SetScore: Invalid score: %d doesn't lie within 0-10", score))
+ return serverResponse{}, e.InvalidScoreError
}
// data to be sent to the server
@@ -92,7 +91,7 @@ func (c Client)SetPriority(id int, priority int) (serverResponse, error) {
// checks if specified priority is valid
if !e.IsValidPriority(priority) {
- return serverResponse{}, errors.New(fmt.Sprintf("SetPriority: Invalid priority: %d doesn't lie within 0-2", priority))
+ return serverResponse{}, e.InvalidPriorityError
}
// data to be sent to the server
@@ -109,7 +108,7 @@ func (c Client)SetRewatchValue(id int, rewatchValue int) (serverResponse, error)
// checks if specified rewatch value is valid
if !e.IsValidRewatchValue(rewatchValue) {
- return serverResponse{}, errors.New(fmt.Sprintf("SetRewatchValue: Invalid rewatch value: %d doesn't lie within 0-5", rewatchValue))
+ return serverResponse{}, e.InvalidRewatchValueError
}
// data to be sent to the server
@@ -165,22 +164,22 @@ func (c Client)UpdateAnime(id int, data UpdateAnimeData) (serverResponse, error)
// checks if specified list status is valid
if !e.IsValidListStatus(data.Status) {
- return serverResponse{}, errors.New(fmt.Sprintf("UpdateAnime: Invalid list status: \"%s\"", data.Status))
+ return serverResponse{}, e.InvalidStatusError
}
// checks if specified score is valid
if !e.IsValidScore(data.Score) {
- return serverResponse{}, errors.New(fmt.Sprintf("UpdateAnime: Invalid score: %d doesn't lie within 0-10", data.Score))
+ return serverResponse{}, e.InvalidScoreError
}
// checks if specified priority is valid
if !e.IsValidPriority(data.Priority) {
- return serverResponse{}, errors.New(fmt.Sprintf("UpdateAnime: Invalid priority: %d doesn't lie within 0-2", data.Priority))
+ return serverResponse{}, e.InvalidPriorityError
}
// checks if specified rewatch value is valid
if !e.IsValidRewatchValue(data.RewatchValue) {
- return serverResponse{}, errors.New(fmt.Sprintf("UpdateAnime: Invalid rewatch value: %d doesn't lie within 0-5", data.RewatchValue))
+ return serverResponse{}, e.InvalidRereadValueError
}
params := url.Values{}