Skip to content

Commit

Permalink
Better error messages when an account does not exist vs. has an error
Browse files Browse the repository at this point in the history
  • Loading branch information
zulucrypto committed Aug 12, 2018
1 parent 3064ab8 commit 351f0a0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public static function fromHorizonResponse(HorizonResponse $response)
{
$rawData = $response->getRawData();

// 404 means the account does not currently exist (it may have been merged)
if (isset($rawData['status']) && $rawData['status'] == 404) {
throw new \InvalidArgumentException('Account does not exist');
}

// Generic catch for other errors
if (isset($rawData['status']) && $rawData['status'] !== 200) {
throw new \InvalidArgumentException('Cannot create account due to error response');
}

$object = new Account($rawData['id']);

$object->accountId = $rawData['account_id'];
Expand Down

0 comments on commit 351f0a0

Please sign in to comment.