summaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/JSONTransport.cpp
blob: 22de7fa8cbeadd449fbd2a2022c0d18cc64629a0 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===-- JSONTransport.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 "lldb/Host/JSONTransport.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <string>

using namespace llvm;
using namespace lldb_private::transport;

char TransportUnhandledContentsError::ID;

TransportUnhandledContentsError::TransportUnhandledContentsError(
    std::string unhandled_contents)
    : m_unhandled_contents(unhandled_contents) {}

void TransportUnhandledContentsError::log(raw_ostream &OS) const {
  OS << "transport EOF with unhandled contents: '" << m_unhandled_contents
     << "'";
}
std::error_code TransportUnhandledContentsError::convertToErrorCode() const {
  return std::make_error_code(std::errc::bad_message);
}

char InvalidParams::ID;

void InvalidParams::log(raw_ostream &OS) const {
  OS << "invalid parameters for method '" << m_method << "': '" << m_context
     << "'";
}
std::error_code InvalidParams::convertToErrorCode() const {
  return std::make_error_code(std::errc::invalid_argument);
}

char MethodNotFound::ID;

void MethodNotFound::log(raw_ostream &OS) const {
  OS << "method not found: '" << m_method << "'";
}

std::error_code MethodNotFound::convertToErrorCode() const {
  // JSON-RPC Method not found
  return std::error_code(MethodNotFound::kErrorCode, std::generic_category());
}