aboutsummaryrefslogtreecommitdiff
path: root/anime/anime.go
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 /anime/anime.go
parent95b8ab702708538ccaf26efd141b448148ac6d6d (diff)
Exported all the errors so programs using this library can customize error messages.
Diffstat (limited to 'anime/anime.go')
-rw-r--r--anime/anime.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/anime/anime.go b/anime/anime.go
index 292abe2..4247381 100644
--- a/anime/anime.go
+++ b/anime/anime.go
@@ -18,7 +18,6 @@ package anime
import (
"encoding/json"
- "errors"
"fmt"
"strconv"
e "github.com/MikunoNaka/MAL2Go/errhandlers"
@@ -88,8 +87,7 @@ func (c Client) GetAnimeById(animeId int, fields []string) (Anime, error) {
BASE_URL + "/" + strconv.Itoa(animeId),
[]string{"fields"},
/* it seems to still return all fields from the API.
- * this might be an issue with MAL itself
- * TODO: look into this */
+ * this might be an issue with MAL itself */
[][]string{fields},
true,
)
@@ -118,7 +116,7 @@ func (c Client) GetAnimeRanking(rankingType string, limit, offset int, fields []
// if ranking type is invalid
if !e.IsValidRankingType(rankingType) {
- return animeRanking, errors.New(fmt.Sprintf("GetAnimeRanking: Invalid ranking type specified: \"%s\"", rankingType))
+ return animeRanking, e.InvalidRankingError
}
endpoint, _ := u.UrlGenerator(
@@ -175,12 +173,12 @@ func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, f
// checks if valid season is specified
if !e.IsValidSeason(season) {
- return seasonalAnime, errors.New(fmt.Sprintf("GetSeasonalAnime: Invalid season specified: \"%s\"", season))
+ return seasonalAnime, e.InvalidSeasonError
}
// checks if valid sort is specified
if !e.IsValidSeasonalSort(sort) {
- return seasonalAnime, errors.New(fmt.Sprintf("GetSeasonalAnime: Invalid sort specified: \"%s\"", sort))
+ return seasonalAnime, e.InvalidSortError
}
endpoint, _ := u.UrlGenerator(