faking an unsuccessful FragmentResponseMessage.
774724
synchronized void repair(SiteTasker task, List<Long> masters, Map<Integer, Long> partitionMasters, boolean balanceSPI)
    {
        // We know that every Site assigned to the MPI (either the main writer or
        // any of the MP read pool) will only have one active transaction at a time,
        // and that we either have active reads or active writes, but never both.
        // Figure out which we're doing, and then poison all of the appropriate sites.
        Map<Long, TransactionTask> currentSet;
        boolean readonly = true;
        if (!m_currentReads.isEmpty()) {
            assert(m_currentWrites.isEmpty());
            if (tmLog.isDebugEnabled()) {
                tmLog.debug("MpTTQ: repairing reads. MigratePartitionLeader:" + balanceSPI);
            }
            for (Long txnId : m_currentReads.keySet()) {
                m_sitePool.repair(txnId, task);
            }
            currentSet = m_currentReads;
        }
        else {
            if (tmLog.isDebugEnabled()) {
                tmLog.debug("MpTTQ: repairing writes. MigratePartitionLeader:" + balanceSPI);
            }
            m_taskQueue.offer(task);
            currentSet = m_currentWrites;
            readonly = false;
        }
        for (Entry<Long, TransactionTask> e : currentSet.entrySet()) {
            if (e.getValue() instanceof MpProcedureTask) {
                MpProcedureTask next = (MpProcedureTask)e.getValue();
                if (tmLog.isDebugEnabled()) {
                    tmLog.debug("MpTTQ: poisoning task: " + next.toShortString());
                }
                next.doRestart(masters, partitionMasters);

                if (!balanceSPI) {
                    MpTransactionState txn = (MpTransactionState)next.getTransactionState();
                    // inject poison pill
                    FragmentTaskMessage dummy = new FragmentTaskMessage(0L, 0L, txn.txnId, txn.uniqueId,
                            false, false, false, txn.isNPartTxn(), txn.getTimetamp());
                    FragmentResponseMessage poison =
                            new FragmentResponseMessage(dummy, 0L); // Don't care about source HSID here
                    // Provide a TransactionRestartException which will be converted
                    // into a ClientResponse.RESTART, so that the MpProcedureTask can
                    // detect the restart and take the appropriate actions.
                    TransactionRestartException restart = new TransactionRestartException(
                            "Transaction being restarted due to fault recovery or shutdown.", next.getTxnId());
                    restart.setMisrouted(false);
                    poison.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, restart);
                    txn.offerReceivedFragmentResponse(poison);
                    if (tmLog.isDebugEnabled()) {
                        tmLog.debug("MpTTQ: restarting:" + next.toShortString());
                    }
                }
            }
        }
        // Now, iterate through the backlog and update the partition masters
        // for all ProcedureTasks
        Iterator<TransactionTask> iter = m_backlog.iterator();
        while (iter.hasNext()) {
            TransactionTask tt = iter.next();
            if (tt instanceof MpProcedureTask) {
                MpProcedureTask next = (MpProcedureTask)tt;

                if (tmLog.isDebugEnabled()) {
                    tmLog.debug("Repair updating task: " + next.toShortString() + " with masters: " + CoreUtils.hsIdCollectionToString(masters));
                }
                next.updateMasters(masters, partitionMasters);
            }
            else if (tt instanceof EveryPartitionTask) {
                EveryPartitionTask next = (EveryPartitionTask)tt;
                if (tmLog.isDebugEnabled())  {
                    tmLog.debug("Repair updating EPT task: " + next + " with masters: " + CoreUtils.hsIdCollectionToString(masters));
                }
                next.updateMasters(masters);
            }
        }
    }
657157
def _validate(self, writing=False):
        """"""
        if (((len(self.fragment_offset) != len(self.fragment_length)) or
             (len(self.fragment_length) != len(self.data_reference)))):
            msg = ("The lengths of the fragment offsets ({len_offsets}), "
                   "fragment lengths ({len_fragments}), and "
                   "data reference items ({len_drefs}) must be the same.")
            msg = msg.format(len_offsets=len(self.fragment_offset),
                             len_fragments=len(self.fragment_length),
                             len_drefs=len(self.data_reference))
            self._dispatch_validation_error(msg, writing=writing)
        if any([x <= 0 for x in self.fragment_offset]):
            msg = "Fragment offsets must all be positive."
            self._dispatch_validation_error(msg, writing=writing)
        if any([x <= 0 for x in self.fragment_length]):
            msg = "Fragment lengths must all be positive."
            self._dispatch_validation_error(msg, writing=writing)
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));
    }
  }
720470
private void failTimedOutMissingContentRequests() {
    if (isStopped()) return;
    if (requestsMissingContent.isEmpty()) return;

    final List<String> toRemove = new ArrayList<>(); // prevent ConcurrentModificationException

    for (final String id : requestsMissingContent.keySet()) {
      final RequestResponseHttpContext requestResponseHttpContext = requestsMissingContent.get(id);

      if (requestResponseHttpContext.requestResponseContext.hasConsumerData()) {
        final RequestParser parser = requestResponseHttpContext.requestResponseContext.consumerData();
        if (parser.hasMissingContentTimeExpired(requestMissingContentTimeout)) {
          requestResponseHttpContext.requestResponseContext.consumerData(null);
          toRemove.add(id);
          requestResponseHttpContext.httpContext.completes.with(Response.of(Response.Status.BadRequest, "Missing content."));
          requestResponseHttpContext.requestResponseContext.consumerData(null);
        }
      } else {
        toRemove.add(id); // already closed?
      }
    }

    for (final String id : toRemove) {
      requestsMissingContent.remove(id);
    }
  }
1175903
private JsonNode processErrorResponse(final JsonNode resp) {
        String errorMessage = resp.get("error").asText();
        if (resp.has("stack")) {
            errorMessage += "\n" + resp.get("stack").asText();
        }

        throw new JsiiException(errorMessage);
    }
1029144
void fakeResponse(
        StatusLine statusline, 
        HeaderGroup responseheaders,
        HttpConnection conn,
        InputStream responseStream
    ) {
        // set used so that the response can be read
        this.used = true;
        this.statusLine = statusline;
        this.responseHeaders = responseheaders;
        this.responseConnection = conn;
        this.responseBody = null;
        this.responseStream = responseStream;
    }
1115774
def fail(self, err='MockupDB query failure', *args, **kwargs):
        
        kwargs.setdefault('flags', 0)
        kwargs['flags'] |= REPLY_FLAGS['QueryFailure']
        kwargs['$err'] = err
        self.replies(*args, **kwargs)
        return True
1023678
def _mock_methodcall(self, methodname, localobject, Params=None, **params):
        # pylint: disable=invalid-name
        
        result = self._fake_invokemethod(methodname, localobject, Params,
                                         **params)

        # Sleep for defined number of seconds
        if self._response_delay:
            time.sleep(self._response_delay)

        return result
122211
function(e, fake, old) {
      var error, msg;

      // "Fake" error applied by the onerror function
      if (fake && !old && !isOpera) {
        return Erroneous._simpleError = e;
      } else if ((fake && old) || isOpera) {
        // This is all we get, parse what we can
        error = new ErroneousError(e);
      } else {
        // A "real" error event, use both the last "fake" error and
        // the real error event

        error = new ErroneousError(e, Erroneous._simpleError);
        Erroneous._simpleError = null;
      }

      Erroneous.pushError(error);
    }
668027
function(err) {
            Dialogs.alert("Error:", err.message || err);
            console.error(err.stack || err.message || err);
            return Q.reject(err);
        }
473572
private String failureProcessing(BackupAgentResponse response) throws BackupExecuteException
   {
      try
      {
         String result =
                  "\nFailure :\n" + "\tstatus code : " + response.getStatus() + "\n" + "\tmessage      : "
                           + new String(response.getResponseData(), "UTF-8") + "\n\n";

         return result;
      }
      catch (UnsupportedEncodingException e)
      {
         throw new BackupExecuteException("Can not encoded the responce : " + e.getMessage(), e);
      }
   }
471136
private void handleRequestSuccess(long requestId, Object response, ThreadContext context) {
    ByteBuf buffer = channel.alloc().buffer(10)
      .writeByte(RESPONSE)
      .writeLong(requestId)
      .writeByte(SUCCESS);

    try {
      writeResponse(buffer, response, context);
    } catch (SerializationException e) {
      handleRequestFailure(requestId, e, context);
      return;
    }

    channel.writeAndFlush(buffer, channel.voidPromise());

    if (response instanceof ReferenceCounted) {
      ((ReferenceCounted) response).release();
    }
  }
614179
def _fail(self, message, text, i):
        """"""

        raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
1310347
public synchronized void onRequestFailed(String message, Throwable ex) {
		String reason = message + ": " + ex.getClass().getName() + ": " + ex.getMessage();
		allRequestsTracker.onRequestFailed(reason);
		recentRequestsTracker.onRequestFailed(reason);
		meter.mark();
	}
953252
@Override
    public void onSuccess(final DMRResponse response) {
        ModelNode result = response.get();
        if (!result.hasDefined(OUTCOME) || result.isFailure()) {
            onFailedOutcome(result);
            abort();
        } else {
            onSuccess(result);
            proceed();
        }
    }
159119
def fail(self, message, param=None, ctx=None):
        """"""
        raise BadParameter(message, ctx=ctx, param=param)
1035425
private void fakeResponse(final HttpMethod method)
        throws IOException, HttpException {
        // What is to follow is an ugly hack.
        // I REALLY hate having to resort to such
        // an appalling trick
        // The only feasible solution is to split monolithic
        // HttpMethod into HttpRequest/HttpResponse pair.
        // That would allow to execute CONNECT method 
        // behind the scene and return CONNECT HttpResponse 
        // object in response to the original request that 
        // contains the correct status line, headers & 
        // response body.
        LOG.debug("CONNECT failed, fake the response for the original method");
        // Pass the status, headers and response stream to the wrapped
        // method.
        // To ensure that the connection is not released more than once
        // this method is still responsible for releasing the connection. 
        // This will happen when the response body is consumed, or when
        // the wrapped method closes the response connection in 
        // releaseConnection().
        if (method instanceof HttpMethodBase) {
            ((HttpMethodBase) method).fakeResponse(
                this.connectMethod.getStatusLine(),
                this.connectMethod.getResponseHeaderGroup(),
                conn,
                this.connectMethod.getResponseBodyAsStream()
            );
            method.getProxyAuthState().setAuthScheme(
                this.connectMethod.getProxyAuthState().getAuthScheme());
            this.connectMethod = null;
        } else {
            releaseConnection = true;
            LOG.warn(
                "Unable to fake response on method as it is not derived from HttpMethodBase.");
        }
    }