LLDB mainline
MCPError.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#ifndef LLDB_PROTOCOL_MCP_MCPERROR_H
10#define LLDB_PROTOCOL_MCP_MCPERROR_H
11
13#include "llvm/Support/Error.h"
14#include <string>
15
17
18class MCPError : public llvm::ErrorInfo<MCPError> {
19public:
20 static char ID;
21
22 MCPError(std::string message, int64_t error_code = kInternalError);
23
24 void log(llvm::raw_ostream &OS) const override;
25 std::error_code convertToErrorCode() const override;
26
27 const std::string &getMessage() const { return m_message; }
28
30
31 static constexpr int64_t kResourceNotFound = -32002;
32 static constexpr int64_t kInternalError = -32603;
33
34private:
35 std::string m_message;
36 int64_t m_error_code;
37};
38
39class UnsupportedURI : public llvm::ErrorInfo<UnsupportedURI> {
40public:
41 static char ID;
42
43 UnsupportedURI(std::string uri);
44
45 void log(llvm::raw_ostream &OS) const override;
46 std::error_code convertToErrorCode() const override;
47
48private:
49 std::string m_uri;
50};
51
52} // namespace lldb_protocol::mcp
53
54#endif
std::error_code convertToErrorCode() const override
Definition MCPError.cpp:24
static constexpr int64_t kInternalError
Definition MCPError.h:32
static constexpr int64_t kResourceNotFound
Definition MCPError.h:31
lldb_protocol::mcp::Error toProtocolError() const
Definition MCPError.cpp:28
void log(llvm::raw_ostream &OS) const override
Definition MCPError.cpp:22
const std::string & getMessage() const
Definition MCPError.h:27
MCPError(std::string message, int64_t error_code=kInternalError)
Definition MCPError.cpp:19
void log(llvm::raw_ostream &OS) const override
Definition MCPError.cpp:37
std::error_code convertToErrorCode() const override
Definition MCPError.cpp:41