bool respondWithError(JSContext *cx, HandleObject self) {
  MOZ_RELEASE_ASSERT(state(self) == State::unhandled || state(self) == State::waitToRespond);
  set_state(self, State::responsedWithError);
  ResponseHandle response{INVALID_HANDLE};
  BodyHandle body{INVALID_HANDLE};
  return HANDLE_RESULT(cx, xqd_resp_new(&response)) && HANDLE_RESULT(cx, xqd_body_new(&body)) &&
         HANDLE_RESULT(cx, xqd_resp_status_set(response, 500)) &&
         HANDLE_RESULT(cx, xqd_resp_send_downstream(response, body, false));
}
bool respondWithError(JSContext *cx, HandleObject self) {
  MOZ_RELEASE_ASSERT(state(self) == State::unhandled || state(self) == State::waitToRespond);
  set_state(self, State::responsedWithError);
  ResponseHandle response{INVALID_HANDLE};
  BodyHandle body{INVALID_HANDLE};
  return HANDLE_RESULT(cx, xqd_resp_new(&response)) && HANDLE_RESULT(cx, xqd_body_new(&body)) &&
         HANDLE_RESULT(cx, xqd_resp_status_set(response, 500)) &&
         HANDLE_RESULT(cx, xqd_resp_send_downstream(response, body, false));
}