fix: handle empty random anime response and improve surprise-me UX

This commit is contained in:
2026-05-15 17:22:56 +02:00
parent 0df43b6f51
commit 4bd6e71e8c
4 changed files with 44 additions and 28 deletions

View File

@@ -63,6 +63,9 @@ func (c *Client) GetRandomAnime(ctx context.Context) (Anime, error) {
if err != nil {
return Anime{}, err
}
if result.Data.MalID == 0 {
return Anime{}, fmt.Errorf("jikan: empty response for random/anime")
}
return result.Data, nil
}