timrourke/incognito

View on GitHub
src/Exception/ExceptionFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
 
declare(strict_types=1);
 
namespace Incognito\Exception;
 
use Exception;
use Aws\Exception\AwsException;
 
class ExceptionFactory
{
public static function make(AwsException $e): Exception
{
$className = $e->getAwsErrorCode();
$fqnCandidate = "\\Incognito\\Exception\\$className";
 
if (class_exists($fqnCandidate, true)) {
return new $fqnCandidate($e);
}
 
return $e;
}
}