diff options
author | Vidhu Kant Sharma <bokuwakanojogahoshii@yahoo.com> | 2022-02-23 16:06:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 16:06:42 +0000 |
commit | 90a9cdb89025930fb7f455b423593a0a35799c4a (patch) | |
tree | 1bbc1d2b57c7eb8a7a36feb51ce0656cf49faf8a /errhandlers/errhandlers.go | |
parent | 8c685067611d829e5fb8eeaaba48508d15cd4dde (diff) | |
parent | e21dc47f2fe1dd3b1ad47224cd9cc3e75d0835fb (diff) |
Merge pull request #6 from MikunoNaka/manga
Manga package completed
Diffstat (limited to 'errhandlers/errhandlers.go')
-rw-r--r-- | errhandlers/errhandlers.go | 22 |
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 { |