Skip to content

Commit

Permalink
Merge pull request #146 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 4.3.4 - error handling improvements
  • Loading branch information
briskt authored May 4, 2023
2 parents 9a429b8 + ab6c1a2 commit faa0e78
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
15 changes: 13 additions & 2 deletions application/common/components/adapters/IdpIdBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use InvalidArgumentException;
use Sil\Idp\IdBroker\Client\IdBrokerClient;
use Sil\Idp\IdBroker\Client\ServiceException;
use Sil\Idp\IdSync\common\components\exceptions\MissingEmailException;
use Sil\Idp\IdSync\common\components\IdBrokerBase;
use Sil\Idp\IdSync\common\models\User;
Expand Down Expand Up @@ -136,10 +137,20 @@ public function getSiteStatus(): string
* @param array|null $fields (Optional:) The list of fields desired about
* each user in the result.
* @return User[] A list of Users.
* @throws Exception
*/
public function listUsers($fields = null)
public function listUsers($fields = null): array
{
return self::getAsUsers($this->getClient()->listUsers($fields));
try {
$result = $this->getClient()->listUsers($fields);
} catch (ServiceException $e) {
$message = 'ID Broker returned non-OK status ' . $e->httpStatusCode;
throw new Exception($message, $e->getCode(), $e);
} catch (Exception $e) {
throw new Exception('error getting users list from ID Broker: ' . $e->getMessage(), $e);
}

return self::getAsUsers($result);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected function getFromIdStore($whereClause): array
$response->getStatusCode(),
$response->getReasonPhrase(),
$response->getBody()
), 1558380644);
), $response->getStatusCode());
}

if (! is_array($body)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getAllActiveUsers()
$response->getStatusCode(),
$response->getReasonPhrase(),
$response->getBody()
), 1642083102);
), $response->getStatusCode());
}

if (! is_array($allUsersInfo)) {
Expand Down
2 changes: 1 addition & 1 deletion application/common/components/adapters/WorkdayIdStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getAllActiveUsers()
$response->getStatusCode(),
$response->getReasonPhrase(),
$response->getBody()
), 1533069498);
), $response->getStatusCode());
}

if (! is_array($allActiveUsers)) {
Expand Down
14 changes: 9 additions & 5 deletions application/common/sync/Synchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,17 @@ public function syncAll()
try {
$idStoreUsers = $this->idStore->getAllActiveUsers();
} catch (Exception $e) {
throw new Exception('Failed to get active users from ID Store: ' . $e->getMessage(), 1669770777);
throw new Exception('Failed to get active users from ID Store: ' . $e->getMessage(), $e->getCode(), $e);
}

$idBrokerUserInfoByEmployeeId = $this->getAllIdBrokerUsersByEmployeeId([
'employee_id',
'active',
]);
try {
$idBrokerUserInfoByEmployeeId = $this->getAllIdBrokerUsersByEmployeeId([
'employee_id',
'active',
]);
} catch (Exception $e) {
throw new Exception('Failed to list users in the ID Broker: ' . $e->getMessage(), $e->getCode(), $e);
}

$numActiveUsersInBroker = $this->getNumActiveUsersInBroker(
$idBrokerUserInfoByEmployeeId
Expand Down

0 comments on commit faa0e78

Please sign in to comment.