httpSendError(message, response, error) {
    const kerr =
      error instanceof KuzzleError
        ? error
        : kerrorHTTP.getFrom(error, "unexpected_error", error.message);

    const content = Buffer.from(JSON.stringify(removeStacktrace(kerr)));

    debugHTTP("[%s] httpSendError: %a", message.connection.id, kerr);

    this.entryPoint.logAccess(
      message.connection,
      new Request(message, {
        connectionId: message.connection.id,
        error: kerr,
      }),
      message,
    );
    this.entryPoint.removeConnection(message.connection.id);

    if (response.aborted) {
      return;
    }

    response.cork(() => {
      response.writeStatus(Buffer.from(kerr.status.toString()));

      for (const header of this.httpConfig.headers) {
        response.writeHeader(header[0], header[1]);
      }

      // Access-Control-Allow-Origin Logic
      if (message.headers && message.headers.origin) {
        if (global.kuzzle.config.internal.allowAllOrigins) {
          response.writeHeader(
            HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
            WILDCARD,
          );
        } else {
          response.writeHeader(
            HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
            Buffer.from(message.headers.origin),
          );
          response.writeHeader(HTTP_HEADER_VARY, ORIGIN);
        }
      }

      response.end(content);
    });
  }
Forward an error response to the client

@param {HttpMessage} message
@param {uWS.HttpResponse} response
@param {Error} error