Check response on exception.

@return true, if successful
183806
public boolean checkResponseForException() {
    if (!finished && rsp != null) {
      Exception e;
      if ((e = rsp.getException()) != null) {
        setError(e.getMessage());
        setFinished();
        return true;
      }
    }
    return false;
  }
895709
public boolean isClientError(IOException e) {
    GoogleJsonResponseException jsonException = getJsonResponseExceptionOrNull(e);
    if (jsonException != null) {
      return (getHttpStatusCode(jsonException)) / 100 == 4;
    }
    return false;
  }
66996
boolean isErrorResponse(HttpResponse response) {
        StatusLine status = response.getStatusLine();
        if (status == null || status.getStatusCode() != 200) {
            return true;
        }
        return false;
    }
1365848
private static boolean falseForNotFound(IOException exception) {
    ComputeException serviceException = translate(exception);
    if (serviceException.getCode() == HTTP_NOT_FOUND) {
      return false;
    }
    throw serviceException;
  }
127937
def _assert_response_success(self, response):
        

        if response.status_code != self._STATUS_CODE_OK:
            raise ExceptionFactory.create_exception_for_response(
                response.status_code,
                self._fetch_all_error_message(response),
                self._fetch_response_id(response)
            )
557034
def has_succeed(self):
        
        status_code = self._response.status_code

        if status_code in [HTTP_CODE_ZERO, HTTP_CODE_SUCCESS, HTTP_CODE_CREATED, HTTP_CODE_EMPTY, HTTP_CODE_MULTIPLE_CHOICES]:
            return True

        if status_code in [HTTP_CODE_BAD_REQUEST, HTTP_CODE_UNAUTHORIZED, HTTP_CODE_PERMISSION_DENIED, HTTP_CODE_NOT_FOUND, HTTP_CODE_METHOD_NOT_ALLOWED, HTTP_CODE_CONNECTION_TIMEOUT, HTTP_CODE_CONFLICT, HTTP_CODE_PRECONDITION_FAILED, HTTP_CODE_INTERNAL_SERVER_ERROR, HTTP_CODE_SERVICE_UNAVAILABLE]:
            return False

        raise Exception('Unknown status code %s.', status_code)
551129
public boolean execute() throws SQLException {
        boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
        SQLExecuteCallback<Boolean> executeCallback = SQLExecuteCallbackFactory.getPreparedSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
        List<Boolean> result = executeCallback(executeCallback);
        if (null == result || result.isEmpty() || null == result.get(0)) {
            return false;
        }
        return result.get(0);
    }
791536
public boolean exists() throws APIException {
        HttpResponse response = client.head(getUrl());
        int status = response.getStatusLine().getStatusCode();
        if(status != 200 && status != 404) {
            throw APIException.fromHttpResponse(response);
        }
        return (200 == status);
    }
474606
private boolean handleException(final Throwable t,
                                  final HttpServletResponse resp,
                                  final boolean serverError) {
    if (serverError) {
      return true;
    }

    try {
      error(t);
      sendError(t, resp);
      return true;
    } catch (Throwable t1) {
      // Pretty much screwed if we get here
      return true;
    }
  }
940147
public function shouldRetry(&$responseString, $exception, $transaction_id)
  {
    // Is transaction - no retry
    if ($transaction_id)
      return false;
    if (!$this->_retryRequests)
      return false;
    if (!is_null($exception)) {
      $this->logFailure();
      if ($this->_numUsed == count($this->_connectionStrings)) {
        return false;
      }
	  $errors = $exception->errors();
      if ($exception->code() == 9006 && $errors[0]['source'] == "CPS_API")
        return true;
      return false;
    }
//     $sp = strpos($responseString, '<cps:error>');
//     if ($sp === FALSE) {
//       $this->logSuccess();
//       return false;
//     }
//     $ep = strrpos($responseString, '</cps:error>');
//     if ($ep === FALSE) {// shouldn't really ever happen, unless our XML response was cut off?
//       $this->logFailure();
//       return ($this->_retryRequests && !$transaction_id);
//     }
//     try {
//       $errorXml = new SimpleXMLElement('<root xmlns:cps="www.clusterpoint.com">' . substr($responseString, $sp, $ep - $sp + strlen('</cps:error>')) . '</root>');
//     } catch (Exception $e) {
//       // Unable to parse errors - shouldn't really ever happen, unless there's something wrong with this function
//       return ($this->_retryRequests && !$transaction_id);
//     }
//     foreach ($errorXml->children('www.clusterpoint.com')->error as $e) {
//       $code = (int)$e->children('')->code;
//       $level = (string)$e->children('')->level;

//       if (($level == 'FAILED') || ($level == 'ERROR') || ($level == 'FATAL') || ($code == 2344)) {
//         // request returned an error, should retry
//         $this->logFailure();
//         return ($this->_retryRequests && !$transaction_id);
//       }
//     }
    $this->logSuccess();
    return false;
  }
1017335
private boolean completeResponse(OperationResponse response, Runnable callback) {
    // If the response is null, that indicates an exception occurred. The best we can do is complete
    // the response in sequential order.
    if (response == null) {
      LOGGER.trace("{} - Completing failed request", state.getSessionId());
      callback.run();
      return true;
    }

    // If the response's event index is greater than the current event index, that indicates that events that were
    // published prior to the response have not yet been completed. Attempt to complete pending events.
    long responseEventIndex = response.eventIndex();
    if (responseEventIndex > eventIndex) {
      // For each pending event with an eventIndex less than or equal to the response eventIndex, complete the event.
      // This is safe since we know that sequenced responses should see sequential order of events.
      EventCallback eventCallback = eventCallbacks.peek();
      while (eventCallback != null && eventCallback.request.eventIndex() <= responseEventIndex) {
        eventCallbacks.remove();
        LOGGER.trace("{} - Completing {}", state.getSessionId(), eventCallback.request);
        eventCallback.run();
        eventIndex = eventCallback.request.eventIndex();
        eventCallback = eventCallbacks.peek();
      }

      // If the response event index is still greater than the last sequenced event index, check
      // enqueued events to determine whether any events can be skipped. This is necessary to
      // ensure that a response with a missing event can still trigger prior events.
      if (responseEventIndex > eventIndex) {
        for (EventCallback event : eventCallbacks) {
          // If the event's previous index is consistent with the current event index and the event
          // index is greater than the response event index, set the response event index to the
          // event's previous index.
          if (event.request.previousIndex() <= eventIndex && event.request.eventIndex() >= response.eventIndex()) {
            responseEventIndex = event.request.previousIndex();
            break;
          }
        }
      }
    }

    // If after completing pending events the eventIndex is greater than or equal to the response's eventIndex, complete the response.
    // Note that the event protocol initializes the eventIndex to the session ID.
    if (responseEventIndex <= eventIndex || (eventIndex == 0 && responseEventIndex == state.getSessionId())) {
      LOGGER.trace("{} - Completing {}", state.getSessionId(), response);
      callback.run();
      return true;
    } else {
      return false;
    }
  }
1122015
public synchronized boolean fail(ServiceException ex) {
        if (completed) {
            return false;
        }
        this.completed = true;
        this.ex = ex;
        notifyAll();
        return true;
    }
190452
private function checkResult($result)
    {
        if ($this->debug) {
            if (in_array($this->format, [self::FORMAT_JSON, self::FORMAT_JSONP])) {
                $result = json_decode($result, true);
            } elseif ($this->format == self::FORMAT_SERIAL) {
                $result = unserialize($result);
            }

            if (is_array($result)) {
                if (isset($result['success']) && $result['success'] == 0 && isset($result['error'])) {
                    throw new \Exception($result['error']);
                }
            }
        }
    }
743433
protected function isResponseOk()
    {
        $status = $this->rawResponse->status;
        if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) {
            return true;
        }
        return false;
    }
493897
@Override
    protected boolean isErrorResponseStatus () {
        int status = getStatus();
        return status != NtStatus.NT_STATUS_INVALID_PARAMETER
                && ! ( status == NtStatus.NT_STATUS_INVALID_PARAMETER
                        && ( this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK || this.ctlCode == Smb2IoctlRequest.FSCTL_SRV_COPYCHUNK_WRITE ) )
                && ! ( status == NtStatus.NT_STATUS_BUFFER_OVERFLOW && ( this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_TRANSCEIVE
                        || this.ctlCode == Smb2IoctlRequest.FSCTL_PIPE_PEEK || this.ctlCode == Smb2IoctlRequest.FSCTL_DFS_GET_REFERRALS ) )
                && super.isErrorResponseStatus();
    }
1311869
private boolean preHandle(HttpRequest request, HttpResponse response, RequestHandler handler) throws Exception {
        for (HandlerInterceptor interceptor : mInterceptorList) {
            if (interceptor.onIntercept(request, response, handler)) return true;
        }
        return false;
    }
1343180
public boolean checkGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        if (!request.getMethod().equals("GET")) {
            response.sendError(405);  // 405 - Incorrect method.
            return false;
        }

        return true;
    }