Skip to content

@chrisguitarguy /AbstractPlatform.php secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
abstract class AbstractPlatform
{
//...
/**
* Throw a more specific exception based on a SQL error code.
*
* @param \PDOException $e
* @throws \Doctrine\DBAL\DBALException
* @return void
*/
public function throwException(\PDOException $e)
{
$error_class = substr((string)$e->getCode(), 0, 2);
switch ($error_class) {
// Connection Exception
case '08':
// pass, connection exceptions seem to be handled elsewhere?
break;
case '0A':
case '0a':
$exception = 'FeatureNotSupportedException';
break;
case '21':
$exception = 'CardinalityViolationException';
break;
case '22':
$exception = 'DataException';
break;
case '23':
$exception = 'IntegrityConstraintException';
break;
case '24':
$exception = 'InvalidCursorStateException';
break;
case '25':
$exception = 'InvalidTransationStateException';
break;
// ... how many of these do the drivers actual use?
}
if (isset($exception)) {
$exception = 'Doctrine\\DBAL\\Exception\\' . $exception;
throw new $exception($e->getMessage(), 0, $e);
}
// if all else fails, just throw a DBALException
throw new DBALException($e->getMessage(), 0, $e);
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.