diff options
| author | horus | 2020-09-23 14:33:19 +0200 |
|---|---|---|
| committer | horus | 2020-09-23 14:33:19 +0200 |
| commit | dc3df89aa73d9df48f92b22378a1307b4ddba3c7 (patch) | |
| tree | eeadf2376d69a7c8479db76fcab4a95600dd6716 /app/AnimeStats.php | |
| parent | 82b2360c4f6186feaa43023dcd79fb89d91c9d4d (diff) | |
| download | senpai-dc3df89aa73d9df48f92b22378a1307b4ddba3c7.tar.gz | |
only save stats if no error
Diffstat (limited to 'app/AnimeStats.php')
| -rw-r--r-- | app/AnimeStats.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/app/AnimeStats.php b/app/AnimeStats.php index a4f3396..9b9b850 100644 --- a/app/AnimeStats.php +++ b/app/AnimeStats.php @@ -94,9 +94,16 @@ class AnimeStats extends Model { $this->season_name= $season_name; } - $animeInfo = $jikan->getAnime( - (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) - ); + try { + $animeInfo = $jikan->getAnime( + (new \Jikan\Request\Anime\AnimeRequest( $this->mal_id )) + ); + } catch (\Exception $e) { + echo "Error requesting AnimeInfo for " . $this->mal_id ."\n"; + echo "Message: " . $e->getMessage(); + echo "\n\n"; + return false; + } $this->score = $animeInfo->getScore(); $this->scored_by = $animeInfo->getScoredBy(); $this->rank = $animeInfo->getRank(); @@ -112,7 +119,7 @@ class AnimeStats extends Model { echo "Error requesting AnimeStats for " . $this->mal_id ."\n"; echo "Message: " . $e->getMessage(); echo "\n\n"; - return; + return false; } $this->watching = $animeStats->getWatching(); @@ -173,6 +180,8 @@ class AnimeStats extends Model { } else { $this->score_10 = 0; } + + return true; } public function anime() { |
