code: protected function createException($error, $errorNo, $sqlState, $query = null)
  	{
  		if (in_array($errorNo, [1216, 1217, 1451, 1452, 1701], true)) {
  			return new ForeignKeyConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif (in_array($errorNo, [1062, 1557, 1569, 1586], true)) {
  			return new UniqueConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif (in_array($errorNo, [1044, 1045, 1046, 1049, 1095, 1142, 1143, 1227, 1370, 2002, 2005], true)) {
  			return new ConnectionException($error, $errorNo, $sqlState);
  
  		} elseif (in_array($errorNo, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) {
  			return new NotNullConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif ($query !== null) {
  			return new QueryException($error, $errorNo, $sqlState, null, $query);
  
  		} else {
  			return new DriverException($error, $errorNo, $sqlState);
  		}
  	}
docs: This method is based on Doctrine\DBAL project.
  @link www.doctrine-project.org