| 1 | //===-- MCPError.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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "MCPError.h" |
| 10 | #include "llvm/Support/Error.h" |
| 11 | #include "llvm/Support/raw_ostream.h" |
| 12 | #include <system_error> |
| 13 | |
| 14 | namespace lldb_private::mcp { |
| 15 | |
| 16 | char MCPError::ID; |
| 17 | char UnsupportedURI::ID; |
| 18 | |
| 19 | MCPError::MCPError(std::string message, int64_t error_code) |
| 20 | : m_message(message), m_error_code(error_code) {} |
| 21 | |
| 22 | void MCPError::log(llvm::raw_ostream &OS) const { OS << m_message; } |
| 23 | |
| 24 | std::error_code MCPError::convertToErrorCode() const { |
| 25 | return llvm::inconvertibleErrorCode(); |
| 26 | } |
| 27 | |
| 28 | protocol::Error MCPError::toProtcolError() const { |
| 29 | protocol::Error error; |
| 30 | error.error.code = m_error_code; |
| 31 | error.error.message = m_message; |
| 32 | return error; |
| 33 | } |
| 34 | |
| 35 | UnsupportedURI::UnsupportedURI(std::string uri) : m_uri(uri) {} |
| 36 | |
| 37 | void UnsupportedURI::log(llvm::raw_ostream &OS) const { |
| 38 | OS << "unsupported uri: "<< m_uri; |
| 39 | } |
| 40 | |
| 41 | std::error_code UnsupportedURI::convertToErrorCode() const { |
| 42 | return llvm::inconvertibleErrorCode(); |
| 43 | } |
| 44 | |
| 45 | } // namespace lldb_private::mcp |
| 46 |
