public static function translate(\Exception $e): \Exception
    {
        if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) {
            return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e);
        } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException ||
                $e instanceof \Doctrine\ORM\UnexpectedResultException ||
                $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException ||
                $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) {
            return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e);
        } elseif ($e instanceof \Doctrine\ORM\PessimisticLockException ||
                $e instanceof \Doctrine\ORM\OptimisticLockException ||
                $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) {
            return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
            return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) {
            return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e);
        } elseif ($e instanceof \Doctrine\ORM\Query\QueryException ||
                $e instanceof \Doctrine\ORM\Mapping\MappingException ||
                $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException ||
                $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) {
            return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e);
        }
        return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e);
    }
public static function translate(\Exception $e): \Exception
    {
        if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) {
            return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e);
        } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException ||
                $e instanceof \Doctrine\ORM\UnexpectedResultException ||
                $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException ||
                $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) {
            return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e);
        } elseif ($e instanceof \Doctrine\ORM\PessimisticLockException ||
                $e instanceof \Doctrine\ORM\OptimisticLockException ||
                $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) {
            return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
            return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e);
        } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) {
            return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e);
        } elseif ($e instanceof \Doctrine\ORM\Query\QueryException ||
                $e instanceof \Doctrine\ORM\Mapping\MappingException ||
                $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException ||
                $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) {
            return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e);
        }
        return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e);
    }
public static function translate ( \ Exception $ e ) : \ Exception { if ( $ e instanceof \ Doctrine \ DBAL \ Exception \ ConnectionException ) { return new \ Caridea \ Dao \ Exception \ Unreachable ( "System unreachable or connection timed out" , $ e -> getCode ( ) , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ ORM \ EntityNotFoundException || $ e instanceof \ Doctrine \ ORM \ UnexpectedResultException || $ e instanceof \ Doctrine \ ODM \ MongoDB \ DocumentNotFoundException || $ e instanceof \ Doctrine \ ODM \ CouchDB \ DocumentNotFoundException ) { return new \ Caridea \ Dao \ Exception \ Unretrievable ( "Data could not be retrieved" , 404 , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ ORM \ PessimisticLockException || $ e instanceof \ Doctrine \ ORM \ OptimisticLockException || $ e instanceof \ Doctrine \ ODM \ CouchDB \ OptimisticLockException ) { return new \ Caridea \ Dao \ Exception \ Conflicting ( "Optimistic or pessimistic concurrency failure" , 409 , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ DBAL \ Exception \ UniqueConstraintViolationException ) { return new \ Caridea \ Dao \ Exception \ Duplicative ( "Unique constraint violation" , 409 , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ DBAL \ Exception \ ConstraintViolationException ) { return new \ Caridea \ Dao \ Exception \ Violating ( "Constraint violation" , 422 , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ ORM \ Query \ QueryException || $ e instanceof \ Doctrine \ ORM \ Mapping \ MappingException || $ e instanceof \ Doctrine \ DBAL \ Exception \ SyntaxErrorException || $ e instanceof \ Doctrine \ Common \ Persistence \ Mapping \ MappingException ) { return new \ Caridea \ Dao \ Exception \ Inoperable ( "Invalid API usage" , 0 , $ e ) ; } return new \ Caridea \ Dao \ Exception \ Generic ( "Uncategorized database error" , 0 , $ e ) ; }
Translates a Doctrine exception.

@param \Exception $e The exception to translate
@return \Exception The exception to use
Translates a Doctrine exception .