36 lines · cpp
1//===-- ResponseHandler.cpp -----------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "ResponseHandler.h"10#include "llvm/ADT/StringRef.h"11#include "llvm/Support/Error.h"12#include "llvm/Support/raw_ostream.h"13 14namespace lldb_dap {15 16void UnknownResponseHandler::operator()(17 llvm::Expected<llvm::json::Value> value) const {18 llvm::errs() << "unexpected response: ";19 if (value) {20 if (std::optional<llvm::StringRef> str = value->getAsString())21 llvm::errs() << *str;22 } else {23 llvm::errs() << "error: " << llvm::toString(value.takeError());24 }25 llvm::errs() << '\n';26}27 28void LogFailureResponseHandler::operator()(29 llvm::Expected<llvm::json::Value> value) const {30 if (!value)31 llvm::errs() << "reverse request \"" << m_command << "\" (" << m_id32 << ") failed: " << llvm::toString(value.takeError()) << '\n';33}34 35} // namespace lldb_dap36