aboutsummaryrefslogtreecommitdiff
path: root/lldb/tools/lldb-dap/Handler/ResponseHandler.cpp
blob: 27a1437de5502d7992a2f2e1ef36e9acc64f6626 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//===-- ResponseHandler.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "ResponseHandler.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/raw_ostream.h"

namespace lldb_dap {

void UnknownResponseHandler::operator()(
    llvm::Expected<llvm::json::Value> value) const {
  llvm::errs() << "unexpected response: ";
  if (value) {
    if (std::optional<llvm::StringRef> str = value->getAsString())
      llvm::errs() << *str;
  } else {
    llvm::errs() << "error: " << llvm::toString(value.takeError());
  }
  llvm::errs() << '\n';
}

void LogFailureResponseHandler::operator()(
    llvm::Expected<llvm::json::Value> value) const {
  if (!value)
    llvm::errs() << "reverse request \"" << m_command << "\" (" << m_id
                 << ") failed: " << llvm::toString(value.takeError()) << '\n';
}

} // namespace lldb_dap