Skip to content

Commit

Permalink
Merge pull request #4 from InternationalCodeCouncil/exception-handling
Browse files Browse the repository at this point in the history
exception-handling
  • Loading branch information
bclarkicc committed May 15, 2023
2 parents 95b4802 + 6513d87 commit e7670b3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Exception/CognitoResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ public function __construct(Throwable $previous = null)
* @param CognitoIdentityProviderException $e
* @return Exception
*/
public static function createFromCognitoException(CognitoIdentityProviderException $e)
public static function createFromCognitoException(Exception $e)
{
$errorClass = "pmill\\AwsCognito\\Exception\\" . $e->getAwsErrorCode();
//If the class is CognitoIdentityProviderException, perform this custom logic
//to get the actual AWS error
if (method_exists($e, 'getAwsErrorCode')) {
$errorClass = "pmill\\AwsCognito\\Exception\\" . $e->getAwsErrorCode();

if (class_exists($errorClass)) {
return new $errorClass($e);
if (class_exists($errorClass)) {
return new $errorClass($e);
}
}

//Otherwise just return the Exception as is
return $e;
}
}

0 comments on commit e7670b3

Please sign in to comment.