Better handle update API errors
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good
All checks were successful
timw4mail/HummingBirdAnimeClient/pipeline/head This commit looks good
This commit is contained in:
parent
5498383587
commit
0f9dd61b6b
@ -144,13 +144,16 @@ abstract class BaseCommand extends Command {
|
||||
{
|
||||
if ($fgColor !== NULL)
|
||||
{
|
||||
$fgColor = (string)$fgColor;
|
||||
$fgColor = (int)$fgColor;
|
||||
}
|
||||
if ($bgColor !== NULL)
|
||||
{
|
||||
$bgColor = (string)$bgColor;
|
||||
$bgColor = (int)$bgColor;
|
||||
}
|
||||
|
||||
// Colorize the CLI output
|
||||
// the documented type for the function is wrong
|
||||
// @phpstan-ignore-next-line
|
||||
$message = Colors::colorize($message, $fgColor, $bgColor);
|
||||
$this->getConsole()->writeln($message);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Command;
|
||||
|
||||
use Aviat\Ion\JsonException;
|
||||
use ConsoleKit\Widgets;
|
||||
|
||||
use Aviat\AnimeClient\API\{
|
||||
@ -287,9 +288,17 @@ final class SyncLists extends BaseCommand {
|
||||
|
||||
// This uses a static so I don't have to fetch this list twice for a count
|
||||
if ($list[$type] === NULL)
|
||||
{
|
||||
try
|
||||
{
|
||||
$list[$type] = $this->anilistModel->getSyncList(strtoupper($type));
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
$this->echoErrorBox('Anlist API exception. Can not sync.');
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
return $list[$type];
|
||||
}
|
||||
@ -599,7 +608,7 @@ final class SyncLists extends BaseCommand {
|
||||
$kitsuItem['data']['ratingTwenty'] !== 0
|
||||
)
|
||||
{
|
||||
$update['data']['ratingTwenty'] = $kitsuItem['data']['ratingTwenty'];
|
||||
$update['data']['ratingTwenty'] = $kitsuItem['data']['rating'];
|
||||
$return['updateType'][] = Enum\API::ANILIST;
|
||||
}
|
||||
else if($dateDiff === self::ANILIST_GREATER && $anilistItem['data']['rating'] !== 0)
|
||||
|
@ -228,7 +228,7 @@ final class Anime extends BaseController {
|
||||
$postData = $transformer->untransform($data);
|
||||
$fullResult = $this->model->updateLibraryItem(FormItem::from($postData));
|
||||
|
||||
if ($fullResult['statusCode'] === 200)
|
||||
if ($fullResult['statusCode'] === 200 && $fullResult['body']['error'] === NULL)
|
||||
{
|
||||
$this->setFlashMessage('Successfully updated.', 'success');
|
||||
$this->cache->clear();
|
||||
|
@ -229,7 +229,7 @@ final class Manga extends Controller {
|
||||
$post_data = $transformer->untransform($data);
|
||||
$full_result = $this->model->updateLibraryItem(FormItem::from($post_data));
|
||||
|
||||
if ($full_result['statusCode'] === 200)
|
||||
if ($full_result['statusCode'] === 200 && $full_result['body']['error'] === NULL)
|
||||
{
|
||||
$this->setFlashMessage('Successfully updated manga.', 'success');
|
||||
$this->cache->clear();
|
||||
|
Loading…
Reference in New Issue
Block a user