code: protected function createException($error, $errorNo, $sqlState, $query = null)
  	{
  		// see codes at http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html
  		if ($sqlState === '0A000' && strpos($error, 'truncate') !== false) {
  			// Foreign key constraint violations during a TRUNCATE operation
  			// are considered "feature not supported" in PostgreSQL.
  			return new ForeignKeyConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif ($sqlState === '23502') {
  			return new NotNullConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif ($sqlState === '23503') {
  			return new ForeignKeyConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif ($sqlState === '23505') {
  			return new UniqueConstraintViolationException($error, $errorNo, $sqlState, null, $query);
  
  		} elseif ($sqlState === null && stripos($error, 'pg_connect()') !== false) {
  			return new ConnectionException($error, $errorNo, $sqlState);
  
  		} 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