53 lines · cpp
1//===-- JSONTransport.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 "lldb/Host/JSONTransport.h"10#include "lldb/Utility/Log.h"11#include "lldb/Utility/Status.h"12#include "llvm/ADT/StringExtras.h"13#include "llvm/Support/raw_ostream.h"14#include <string>15 16using namespace llvm;17using namespace lldb_private::transport;18 19char TransportUnhandledContentsError::ID;20 21TransportUnhandledContentsError::TransportUnhandledContentsError(22 std::string unhandled_contents)23 : m_unhandled_contents(unhandled_contents) {}24 25void TransportUnhandledContentsError::log(raw_ostream &OS) const {26 OS << "transport EOF with unhandled contents: '" << m_unhandled_contents27 << "'";28}29std::error_code TransportUnhandledContentsError::convertToErrorCode() const {30 return std::make_error_code(std::errc::bad_message);31}32 33char InvalidParams::ID;34 35void InvalidParams::log(raw_ostream &OS) const {36 OS << "invalid parameters for method '" << m_method << "': '" << m_context37 << "'";38}39std::error_code InvalidParams::convertToErrorCode() const {40 return std::make_error_code(std::errc::invalid_argument);41}42 43char MethodNotFound::ID;44 45void MethodNotFound::log(raw_ostream &OS) const {46 OS << "method not found: '" << m_method << "'";47}48 49std::error_code MethodNotFound::convertToErrorCode() const {50 // JSON-RPC Method not found51 return std::error_code(MethodNotFound::kErrorCode, std::generic_category());52}53