Skip to content

Commit

Permalink
Add legacy platform exception
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekz committed Jul 27, 2017
1 parent 28965e1 commit 5d1dc83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Destiny/Support/Exceptions/LegacyPlatformException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Destiny\Support\Exceptions;

class LegacyPlatformException extends \RuntimeException
{
}
13 changes: 12 additions & 1 deletion src/Destiny/Support/Traits/MakesApiConnections.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Destiny\Support\Traits;

use Destiny\Support\Exceptions\BungieUnavailableException;
use Destiny\Support\Exceptions\LegacyPlatformException;
use GuzzleHttp\Client;

trait MakesApiConnections
Expand Down Expand Up @@ -31,6 +32,16 @@ protected function requestJson($url)
throw new BungieUnavailableException();
}

return json_decode($response->getBody()->getContents(), true);
$json = json_decode($response->getBody()->getContents(), true);

if (isset($json['ErrorCode'])) {
switch ($json['ErrorCode']) {
case 1670:
throw new LegacyPlatformException();
break;
}
}

return $json;
}
}

0 comments on commit 5d1dc83

Please sign in to comment.