Callback for when the bureau client acknowledges the failure to create an agent.
347098
protected void agentCreationFailed (ClientObject client, int agentId)
    {
        FoundAgent found = resolve(client, agentId, "agentCreationFailed");
        if (found == null) {
            return;
        }

        log.info("Agent creation failed", "agent", found.agent.which());

        if (found.state == AgentState.STARTED ||
            found.state == AgentState.STILL_BORN) {
            found.bureau.agentStates.remove(found.agent);
            _omgr.destroyObject(found.agent.getOid());

        } else if (found.state == AgentState.PENDING ||
            found.state == AgentState.RUNNING ||
            found.state == AgentState.DESTROYED) {
            log.warning("Ignoring failure of creation of an agent in an unexpected state",
                        "state", found.state, "agent", found.agent.which());
        }

        found.bureau.summarize();
    }
416216
void handleAgentCompleteEvent(AgentCompleteEvent event)
    {
        AsteriskAgentImpl agent = getAgentByAgentId(event.getChannel());
        if (agent == null)
        {
            logger.error("Ignored AgentCompleteEvent for unknown agent " + event.getChannel());
            return;
        }
        agent.updateState(AgentState.AGENT_IDLE);
    }
1313869
def agent_error(e: requests.HTTPError, fatal=True):
    
    try:
        data = e.response.json()
        details = data['detail']  # type: str
    except JSONDecodeError:
        details = e.response.text or str(e.response)

    lines = ('[AGENT] {}'.format(line) for line in details.splitlines())
    msg = '\n' + '\n'.join(lines)

    if fatal:
        fatal_error(msg)
    else:
        error(msg)
539469
function onFailure(err) {
          onTimelyResponse(spec.code);

          logError(`Server call for ${spec.code} failed: ${err}. Continuing without bids.`);
          onResponse();
        }
230026
function handleFailure(err) {
    // Respond back to SWF failing the workflow
    winston.log('error', 'An problem occured in the execution of workflow: %s, failing due to: ', self.name, err.stack);
    decisionTask.response.fail('Workflow failed', err, function (err) {
      if (err) {
        winston.log('error', 'Unable to mark workflow: %s as failed due to: %s', self.name, JSON.stringify(err));
        return;
      }
    });
  }
552558
def on_failure(self, entity):
        
        logger.error("Login failed, reason: %s" % entity.getReason())
        self.connected = False
235672
function failed(err, userId, channel, target) {
        if (err && typeof err === 'object') {
            err.userId  = userId
            err.channel = channel
            err.target  = target
        }

        errors.push(err)
        done()
    }
276253
def raise_api_error(resp, state=None):
    """"""
    # TODO: Refactor into an Exception class
    error_code = resp.status_code

    if error_code == 402:
        error_message = (
            "Please add a payment method to upload more samples. If you continue to "
            "experience problems, contact us at help@onecodex.com for assistance."
        )
    elif error_code == 403:
        error_message = "Please login to your One Codex account or pass the appropriate API key."
    else:
        try:
            error_json = resp.json()
        except ValueError:
            error_json = {}

        if "msg" in error_json:
            error_message = error_json["msg"].rstrip(".")
        elif "message" in error_json:
            error_message = error_json["message"].rstrip(".")
        else:
            error_message = None

        if state == "init" and not error_message:
            error_message = (
                "Could not initialize upload. Are you logged in? If this problem "
                "continues, please contact help@onecodex.com for assistance."
            )
        elif state == "upload" and not error_message:
            error_message = (
                "File could not be uploaded. If this problem continues, please contact "
                "help@onecodex.com for assistance."
            )
        elif state == "callback" and not error_message:
            error_message = (
                "Callback could not be completed. If this problem continues, please "
                "contact help@onecodex.com for assistance."
            )

    if error_message is None:
        error_message = "Upload failed. Please contact help@onecodex.com for assistance."

    raise UploadException(error_message)
1330175
protected void handleAppendResponseError(MemberState member, AppendRequest request, AppendResponse response) {
    // If any other error occurred, increment the failure count for the member. Log the first three failures,
    // and thereafter log 1% of the failures. This keeps the log from filling up with annoying error messages
    // when attempting to send entries to down followers.
    int failures = member.incrementFailureCount();
    if (failures <= 3 || failures % 100 == 0) {
      logger.warn("{} - AppendRequest to {} failed: {}", context.getCluster().member().address(), member.getMember().serverAddress(), response.error() != null ? response.error() : "");
    }
  }
304010
public synchronized void fail (Throwable error) {
    if (pixelWidth == 0) pixelWidth = 50;
    if (pixelHeight == 0) pixelHeight = 50;
    setBitmap(createErrorBitmap(pixelWidth, pixelHeight));
    ((RPromise<Image>)state).fail(error); // state is a deferred promise
  }
392262
protected void handleConfigureRequestFailure(MemberState member, ConfigureRequest request, Throwable error) {
    // Log the failed attempt to contact the member.
    failAttempt(member, error);
  }
295212
function Session_createAgent(agentInfo, cb) {
  if (!this._channel) return

  DEBUG("session.createAgent()", utils.JS(agentInfo))

  var session = this

  this._ragentServer.send("createAgent", agentInfo, onResponse)

  //-----------------------------------
  function onResponse(err, agentInfo) {
    if (err) {
      DEBUG("session.createAgent() error", err)
      return cb(err)
    }

    DEBUG("session.createAgent() success", utils.JS(agentInfo))
    var agent = agents.createAgent(session, agentInfo)
    session._agents.set(agentInfo.id, agent)

    cb(null, agent)
  }
}
1205446
def _except_if_failed(cls, event):
        """"""
        if event.success is None:
            raise IOTSyncTimeout('Requested timed out', event)
        if not event.success:
            msg = "Request failed, unknown error"
            if isinstance(event.payload, Mapping):
                if P_MESSAGE in event.payload:
                    msg = event.payload[P_MESSAGE]
                try:
                    exc_class = cls.__exception_mapping[event.payload[P_CODE]]
                except KeyError:
                    pass
                else:
                    raise exc_class(msg, event)

            raise IOTException(msg, event)
611874
function onClientError(err, res) {
    if ((err || {}).name === 'SizeLimitExceededError') {
      onSearchEnd(res);
      return;
    }

    client.unbind();
    log.error(err, '[%s] An error occurred performing the requested LDAP search on %s (%j)',
              (err || {}).errno || 'UNKNOWN', baseDN, opts);
    if (callback) callback(err);
  }
16011
protected void agentCreated (ClientObject client, int agentId)
    {
        FoundAgent found = resolve(client, agentId, "agentCreated");
        if (found == null) {
            return;
        }

        log.info("Agent creation confirmed", "agent", found.agent.which());

        if (found.state == AgentState.STARTED) {
            found.bureau.agentStates.put(found.agent, AgentState.RUNNING);
            found.agent.setClientOid(client.getOid());

        } else if (found.state == AgentState.STILL_BORN) {
            // TODO: have a timeout for this in case the client is misbehaving or hung
            BureauSender.destroyAgent(found.bureau.clientObj, agentId);
            found.bureau.agentStates.put(found.agent, AgentState.DESTROYED);

        } else if (found.state == AgentState.PENDING ||
            found.state == AgentState.RUNNING ||
            found.state == AgentState.DESTROYED) {
            log.warning("Ignoring confirmation of creation of an agent in an unexpected state",
                        "state", found.state, "agent", found.agent.which());
        }

        found.bureau.summarize();
    }
1095673
public void startAgent (AgentObject agent)
    {
        agent.setLocal(AgentData.class, new AgentData());

        Bureau bureau = _bureaus.get(agent.bureauId);
        if (bureau != null && bureau.ready()) {
            _omgr.registerObject(agent);

            log.info("Bureau ready, sending createAgent", "agent", agent.which());
            BureauSender.createAgent(bureau.clientObj, agent.getOid());
            bureau.agentStates.put(agent, AgentState.STARTED);
            bureau.summarize();
            return;
        }

        if (bureau == null) {
            LauncherEntry launcherEntry = _launchers.get(agent.bureauType);
            if (launcherEntry == null) {
                log.warning("Launcher not found", "agent", agent.which());
                return;
            }

            log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry);
            bureau = new Bureau();
            bureau.bureauId = agent.bureauId;
            bureau.token = generateToken(bureau.bureauId);
            bureau.launcherEntry = launcherEntry;
            _invoker.postUnit(new LauncherUnit(bureau, _omgr));
            _bureaus.put(agent.bureauId, bureau);
        }

        _omgr.registerObject(agent);
        bureau.agentStates.put(agent, AgentState.PENDING);

        log.info("Bureau not ready, pending agent", "agent", agent.which());
        bureau.summarize();
    }
1051402
@Override
  public void handleFailedDispatch(long clientId, long failedTime) {
    ClientData clientData = core.getClientData(clientId);
    if (failedTime == -1 || clientData == null)
      return;
    
    // We only add it and don't update it because we are interested in
    // keeping track of the first moment it failed
    if (clientData.markedAsFailedTime == -1) {
      clientData.markedAsFailedTime = failedTime;
      LOG.info("Marked client " + clientId + " as failed at " + failedTime);
    }

    clientData.lastSentTime = failedTime;
  }