:return: the StreamingQueryException if the query was terminated by an exception, or None.
971631
def exception(self):
        
        if self._jsq.exception().isDefined():
            je = self._jsq.exception().get()
            msg = je.toString().split(': ', 1)[1]  # Drop the Java StreamingQueryException type info
            stackTrace = '\n\t at '.join(map(lambda x: x.toString(), je.getStackTrace()))
            return StreamingQueryException(msg, stackTrace, je.getCause())
        else:
            return None
6796
def query(self, query):
        
        if not isinstance(query, bytes):
            query = query.encode("utf-8")

        retry_num = 0
        retry_exceptions = []
        do_retry = True if self.max_retry_count > 0 else False
        while retry_num <= self.max_retry_count:
            if retry_num > 0:
                time.sleep(self.retry_timeout)
            retry_num += 1
            try:
                f = urlopen(self.url, query)
            except HTTPError as e:
                f = e

            response = f.read(self.read_chunk_size)
            while True:
                data = f.read(self.read_chunk_size)
                if len(data) == 0:
                    break
                response = response + data
            f.close()

            if f.code == 200:
                if PY2:
                    http_info = f.info()
                    content_type = http_info.getheader("content-type")
                else:
                    content_type = f.getheader("Content-Type")

                if content_type == "application/json":
                    return self.parse_json(response)

                if content_type == "application/osm3s+xml":
                    return self.parse_xml(response)

                e = exception.OverpassUnknownContentType(content_type)
                if not do_retry:
                    raise e
                retry_exceptions.append(e)
                continue

            if f.code == 400:
                msgs = []
                for msg in self._regex_extract_error_msg.finditer(response):
                    tmp = self._regex_remove_tag.sub(b"", msg.group("msg"))
                    try:
                        tmp = tmp.decode("utf-8")
                    except UnicodeDecodeError:
                        tmp = repr(tmp)
                    msgs.append(tmp)

                e = exception.OverpassBadRequest(
                    query,
                    msgs=msgs
                )
                if not do_retry:
                    raise e
                retry_exceptions.append(e)
                continue

            if f.code == 429:
                e = exception.OverpassTooManyRequests
                if not do_retry:
                    raise e
                retry_exceptions.append(e)
                continue

            if f.code == 504:
                e = exception.OverpassGatewayTimeout
                if not do_retry:
                    raise e
                retry_exceptions.append(e)
                continue

            e = exception.OverpassUnknownHTTPStatusCode(f.code)
            if not do_retry:
                raise e
            retry_exceptions.append(e)
            continue

        raise exception.MaxRetriesReached(retry_count=retry_num, exceptions=retry_exceptions)
905896
@Override
    public SQLException attempt() {
        try {
            Connection con = this.connectionSpec.getOrCreate();
            con.setReadOnly(true);
            try {
                Statement stmt = con.createStatement(
                        ResultSet.TYPE_FORWARD_ONLY,
                        ResultSet.CONCUR_READ_ONLY);
                stmt.setFetchSize(AbstractSQLGenerator.FETCH_SIZE);
                if (this.queryTimeout != null) {
                    stmt.setQueryTimeout(this.queryTimeout);
                }
                try {
                    SQLExecutor.executeSQL(con, stmt, this.query,
                            this.resultProcessor);
                    stmt.close();
                    stmt = null;
                } finally {
                    if (stmt != null) {
                        try {
                            stmt.close();
                        } catch (SQLException e) {
                        }
                    }
                }
                con.close();
                con = null;
            } finally {
                if (con != null) {
                    try {
                        con.close();
                    } catch (SQLException e) {
                    }
                }
            }
            return null;
        } catch (SQLException ex) {
            return ex;
        }
    }
993757
def search_exception(exception, delegate = nil)
      query = ExceptionHound.new(exception).query
      search_query(query, delegate)
    end
426894
public static boolean isUnsupportedException(SQLException sqle){
        if(sqle instanceof SQLFeatureNotSupportedException)
            return true;
        
        String state = sqle.getSQLState() == null ? "" : sqle.getSQLState();
        int code = sqle.getErrorCode();

        return state.startsWith("0A") || 0x0A000 == code // standard code for unsupported operation
            || state.startsWith("HYC00") // ODBC error code
            || code == -79700 && "IX000".equals(state); // Informix specific
    }
1051049
private boolean query()
		throws SQLException
	{
		statement = this.connection.createStatement();

		String query = "SELECT PrimaryKey, RevisionCounter,"
				+ " RevisionID, ArticleID, Timestamp, FullRevisionID "
				+ "FROM revisions";

		if (primaryKey > 0) {
			query += " WHERE PrimaryKey > " + primaryKey;
		}

		if (MAX_NUMBER_RESULTS > 0) {
			query += " LIMIT " + MAX_NUMBER_RESULTS;
		}

		result = statement.executeQuery(query);
		return result.next();
	}
800610
@Override
  public void queryFail(HeadersAmp headers, long qid, Throwable exn)
  {
    try (OutboxAmp outbox = OutboxAmp.currentOrCreate(_serviceRef.services())) {
      _serviceRef.offer(new QueryErrorMessage(outbox,
                                              _serviceRef, 
                                              headers,
                                              _serviceRef.stub(),
                                              qid, 
                                              exn));
    }
  }
920640
public static void checkConnectionException(SQLException exception,
      MariaDbConnection connection) {
    if (exception.getSQLState() != null) {
      SqlStates state = SqlStates.fromString(exception.getSQLState());
      if (SqlStates.CONNECTION_EXCEPTION.equals(state)) {
        connection.setHostFailed();
        if (connection.pooledConnection != null) {
          connection.pooledConnection.fireConnectionErrorOccured(exception);
        }
      }
    }
  }
1080307
def get_query_error(self,i):
    
    x = self._query_hpas[i]
    h = x['hpa']
    pos = x['pos']
    prob = 0
    be = BaseError('query')
    be.set_observable(h.get_target(),h.get_query())
    if i != 0 and pos == 0: # check for a total deletion before
      prev = x['prev-hpa']
      if len(prev.get_query()) == 0: # total deletion
        be.set_unobserved_before(len(prev.get_target()),0,prev.get_target()[0],0.5)
    if i != len(self._query_hpas)-1 and pos == len(h.get_query())-1: # check for a total deletion before
      if x['next-hpa']:
        foll = x['next-hpa']
        if len(foll.get_query()) == 0: # total deletion
          be.set_unobserved_after(len(foll.get_target()),0,foll.get_target()[0],0.5)
    return be
293334
def _on_dynamodb_exception(self, error):
        
        if isinstance(error, exceptions.ConditionalCheckFailedException):
            raise web.HTTPError(409, reason='Condition Check Failure')
        elif isinstance(error, exceptions.NoCredentialsError):
            if _no_creds_should_return_429():
                raise web.HTTPError(429, reason='Instance Credentials Failure')
        elif isinstance(error, (exceptions.ThroughputExceeded,
                                exceptions.ThrottlingException)):
            raise web.HTTPError(429, reason='Too Many Requests')
        if hasattr(self, 'logger'):
            self.logger.error('DynamoDB Error: %s', error)
        raise web.HTTPError(500, reason=str(error))
174392
final public function createQueryException(string $query, \Throwable $previous = null): QueryException
    {
        return new QueryException($this->getLastMessage() ?: 'Database error', $query, 0, $previous);
    }
1337450
public static SQLException toSQLException(Throwable ex) {
        if (ex == null)
            return null; 

        if (ex instanceof SQLException)
            return (SQLException) ex;

        if (ex instanceof ResourceException)
            return toSQLException((ResourceException) ex);

        // Link the original exception to the new SQLException. 

        SQLException sqlX = new SQLException(ex.getClass().getName() + ": " + ex.getMessage());
        sqlX.initCause(ex);

        return sqlX;
    }
516291
private BadRequestException getBadRequestException(Exception ex) {
	    return (BadRequestException) ExceptionUtils
	            .getThrowables(ex)[ExceptionUtils.indexOfThrowable(ex, BadRequestException.class)];
	}
1024042
protected function exceptionIfNotQuery()
    {
        if (!$this->isQuery()) {
            throw new RuntimeException(
                Message::get(Message::DB_SQL_NOT_QUERY),
                Message::DB_SQL_NOT_QUERY
            );
        }
    }
189924
public static SQLException unwrapSQLException(Throwable throwable) {
        if (throwable == null) {
            return null;
        } else if (throwable instanceof SQLException) {
            return (SQLException) throwable;
        } else if (throwable.getCause() != null) {
            // recursive call to unwrap the cause
            return unwrapSQLException(throwable.getCause());
        } else {
            // didn't find any SQLException in the cause stack
            return null;
        }
    }
1033043
def _try_fetch(self, size=None):
        
        if self._query_job is None:
            raise exceptions.InterfaceError(
                "No query results: execute() must be called before fetch."
            )

        is_dml = (
            self._query_job.statement_type
            and self._query_job.statement_type.upper() != "SELECT"
        )
        if is_dml:
            self._query_data = iter([])
            return

        if self._query_data is None:
            client = self.connection._client
            rows_iter = client.list_rows(
                self._query_job.destination,
                selected_fields=self._query_job._query_results.schema,
                page_size=self.arraysize,
            )
            self._query_data = iter(rows_iter)
860106
private static void handleSQLException(SQLException e, String poolName, String sql) {

    YankSQLException yankSQLException = new YankSQLException(e, poolName, sql);

    if (throwWrappedExceptions) {
      throw yankSQLException;
    } else {
      logger.error(yankSQLException.getMessage(), yankSQLException);
    }
  }