aboutsummaryrefslogtreecommitdiff
path: root/errhandlers/errhandlers.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-23 21:32:44 +0530
committerVidhu Kant Sharma <vidhukant@protonmail.ch>2022-02-23 21:32:44 +0530
commite21dc47f2fe1dd3b1ad47224cd9cc3e75d0835fb (patch)
tree1bbc1d2b57c7eb8a7a36feb51ce0656cf49faf8a /errhandlers/errhandlers.go
parent7a68abbc9e492934cf4170d5a0ff52a456fe92bd (diff)
finalized manga package with all the endpoints added
Diffstat (limited to 'errhandlers/errhandlers.go')
-rw-r--r--errhandlers/errhandlers.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/errhandlers/errhandlers.go b/errhandlers/errhandlers.go
index 14c1d33..5f4db25 100644
--- a/errhandlers/errhandlers.go
+++ b/errhandlers/errhandlers.go
@@ -22,8 +22,9 @@ import (
"github.com/MikunoNaka/MAL2Go/util"
)
-// if fields aren't specified
+// this is only for anime fields
func FieldsErrHandler(fields []string) ([]string, error) {
+ // if fields aren't specified
if cap(fields) == 0 {
// uses all the default fields if none specified
return util.DefaultFields, nil
@@ -40,6 +41,25 @@ func FieldsErrHandler(fields []string) ([]string, error) {
return fields, nil
}
+// only for manga fields
+func MangaFieldsErrHandler(fields []string) ([]string, error) {
+ // if fields aren't specified
+ if cap(fields) == 0 {
+ // uses all the default fields if none specified
+ return util.DefaultMangaFields, nil
+ }
+
+ // checks if each given field is valid
+ for _, j := range(fields) {
+ if !IsValidMangaField(j) {
+ return []string{}, errors.New(fmt.Sprintf("InvalidFieldError: Invalid field specified: \"%s\"", j))
+ }
+ }
+
+ // everything's fine!
+ return fields, nil
+}
+
// if limit or error specified are above the limit
func LimitErrHandler(limit, maxLimit int) error {
if limit > maxLimit {