--- SEND ERROR ---
331162
public synchronized boolean sendError(Throwable cause) {
		if (cause == null) {
			throw new IllegalArgumentException("Unable to send \"null\" as Exception!");
		}
		if (closed.compareAndSet(false, true)) {
			this.cause = cause;
			if (listeners != null) {
				try {
					if (listeners.length == 1) {
						listeners[0].onPacket(null, cause, true);
					} else {
						for (PacketListener listener : listeners) {
							listener.onPacket(null, cause, true);
						}
					}
				} catch (MoleculerError moleculerError) {
					throw moleculerError;
				} catch (Throwable error) {
					throw new MoleculerClientError("Unable to send error to stream listener!", error, nodeID, null);
				}
			}
			return true;
		}
		return false;
	}
1158419
function sendResponse(code, message, statusCode) {
    /*jshint validthis:true*/
    var res = this;
    var data;
    var result;

    if (!res) {
      throw new Error('You called `error()`, detatched send from the response object');
    }

    code = code || 'UKN';
    message = message || (errors[code] && errors[code].message) || 'Unknown error occurred';
    statusCode = statusCode || (errors[code] && errors[code].statusCode) || '200';
    data = { code: code, message: message };

    res.setHeader('Content-Type', 'application/json');
    //res.statusCode = statusCode;
    if (code && 'object' === typeof code) {
      if (code.error) {
        code = code.error;
      }
      if (/message/.test(JSON.stringify(code))) {
        // '{}' !== JSON.stringify(code)
        data = code;
      } else {
        data = { type: code.type, name: code.name, message: code.message || code.toString() };
      }
    }

    result = JSON.stringify({ error: data }, null, '  ');
    res.end(result);
  }
1292309
@Override
  public final void error(String key, String error) throws IOException {
    if (key != null) {
      add(key, false);
      setError(newCurrentPosition, error, newCurrentExisting);
    }
  }
1354819
def sendError(self, errorcode):
        """"""
        log.debug("In sendError, being asked to send error %d", errorcode)
        errpkt = TftpPacketERR()
        errpkt.errorcode = errorcode
        if self.context.tidport == None:
            log.debug("Error packet received outside session. Discarding")
        else:
            self.context.sock.sendto(errpkt.encode().buffer,
                                     (self.context.host,
                                      self.context.tidport))
        self.context.last_pkt = errpkt
318677
public static void sendError(int errorCode, String errorContent) {
		HttpServletResponse response = Response.getServletResponse();
		try {
			if(HuluSetting.isDevMode) {
				response.sendError(errorCode);
			}else {
				response.sendError(errorCode, errorContent);
			}
		} catch (IOException e) {
			log.error(e, "Error when sendError!");
		}
	}
298938
public void sendError(HttpServletRequest request, HttpServletResponse response, ServletErrorReport e)
	{
		context.sendError(request, response, e);
	}
963283
@Override
    public void sendError(int sc, String msg) throws IOException {
        if (isCommitted()) {
            throw new IllegalStateException("Cannot set error status - response is already committed");
        }
        notifyBeforeCommit();
        super.sendError(sc, msg);
        setCommitted();
    }
640008
function (error, response) {
        if (!_.isNull(error)) {
            error = _.createError(error);
        } else if (!_.isNull(response) && (response.status >= 400 || response.status === 0)) {
            error = _.createError(null, response);
            response = null;
        }
        callback(error, response);
    }
488019
function onError( error ) {
		self.req.error = error;
		if ( process.connected ) {
			// TODO: log (or not; serialize in output message?)
			console.error( process.pid, 'request', error );
		}
	}
1278390
function writeError(code, res, msg) {
	try{
		if (res.headerSent) {
			logger.error("header Sent:", res.req.method, res.req.originalUrl);
		}
		if (httpCodeMapping) {
			code = mapHttpStatusCode(code);
		}
		msg = msg instanceof Error ? msg.message : msg;
		addStrictTransportHeaders(res);
		setResponseNoCache(res);
		if (typeof msg === 'string') {
			var err = JSON.stringify({Severity: "Error", Message: msg});
			res.setHeader('Content-Type', 'application/json');
			res.setHeader('Content-Length', err.length);
			res.writeHead(code);
			res.end(err);
		} else {
			res.writeHead(code);
			res.end();
		}
	}catch(err){
		logger.error(res.req.originalUrl , err.message);
		throw err;
	}
}
673362
@Override
    public void sendError(HttpError error) throws MessageSentException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Called sendError with: " + error);
        }
        if (!headersParsed()) {
            // request message must have the headers parsed prior to sending
            // any data out (this is a completely invalid state in the channel
            // above)
            // In this case, the app should not be re-using this so just close it
            IOException ioe = new IOException("Request not read yet");
            FFDCFilter.processException(ioe, CLASS_NAME + ".sendError", "1116");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Attempt to send response without a request msg");
            }
            finishSendError(ioe);
            return;
        }

        // bail if the headers have already been sent
        if (headersSent()) {
            throw new MessageSentException("Message already sent");
        }

        // ensure error is legal
        if (null == error) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Reset null error to Internal Server Error");
            }
            error = StatusCodes.INTERNAL_ERROR.getHttpError();
        }

        // set up the response message and then send it out
        getResponse().setStatusCode(error.getErrorCode());
        if (getResponse().getStatusCode().isErrorCode()) {
            // PK30169 - some "error" status codes do not disable persistence
            setPersistent(false);
        }
        getVC().getStateMap().put(HTTP_ERROR_IDENTIFIER, error);
        if (getHttpConfig().getDebugLog().isEnabled(DebugLog.Level.ERROR)) {
            getHttpConfig().getDebugLog().log(DebugLog.Level.ERROR, HttpMessages.MSG_CONN_SENDERROR + error.getErrorCode(), this);
        }
        // now figure out what buffers, if any, to send as the response body
        WsByteBuffer[] body = loadErrorBody(error, getMyRequest(), getResponse());
        VirtualConnection rc = finishResponseMessage(body, HttpISCWriteErrorCallback.getRef(), false);
        if (null != rc) {
            finishSendError(error.getClosingException());
        }
    }
491749
@Override
    public void errormsg(String key, Object... args) {
        if (isRunningInteractive()) {
            rawout(prefixError(messageFormat(key, args)));
        } else {
            startmsg(key, args);
        }
    }
437480
function sendMessage(client, to, message, callback) {
	resolveID(client, to, function(channelID) {
		client._req('post', Endpoints.MESSAGES(channelID), message, function(err, res) {
			handleResCB("Unable to send messages", err, res, callback);
		});
	});
}
612545
function connectionError(response, message, body) {
  var content = errorContent(ErrorType.connection, message, body);
  send(response, content, StatusCode.badGateway);
}
645606
function error () {
  if (mocking) {
    cli.stderr += stripAnsi(concatArguments(arguments) + '\n')
  } else {
    console.error.apply(null, arguments)
  }
}
498036
function timeOutError(response, message, body) {
  var content = errorContent(ErrorType.connection, message, body);
  send(response, content, StatusCode.timeout);
}
95014
public void error(String format, Object... args) throws IOException, ServletException {
        error(String.format(format,args));
    }