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
12#include "llvm/Support/Error.h"
13#include <string>
14
16
17class MCPError : public llvm::ErrorInfo<MCPError> {
18public:
19 static char ID;
20
21 MCPError(std::string message, int64_t error_code = kInternalError);
22
23 void log(llvm::raw_ostream &OS) const override;
24 std::error_code convertToErrorCode() const override;
25
26 const std::string &getMessage() const { return m_message; }
27
28 static constexpr int64_t kResourceNotFound = -32002;
29 static constexpr int64_t kInternalError = -32603;
30
31private:
32 std::string m_message;
34};
35
36class UnsupportedURI : public llvm::ErrorInfo<UnsupportedURI> {
37public:
38 static char ID;
39
40 UnsupportedURI(std::string uri);
41
42 void log(llvm::raw_ostream &OS) const override;
43 std::error_code convertToErrorCode() const override;
44
45private:
46 std::string m_uri;
47};
48
49} // namespace lldb_protocol::mcp
50
51#endif
std::error_code convertToErrorCode() const override
Definition MCPError.cpp:24
static constexpr int64_t kInternalError
Definition MCPError.h:29
static constexpr int64_t kResourceNotFound
Definition MCPError.h:28
void log(llvm::raw_ostream &OS) const override
Definition MCPError.cpp:22
const std::string & getMessage() const
Definition MCPError.h:26
MCPError(std::string message, int64_t error_code=kInternalError)
Definition MCPError.cpp:19
void log(llvm::raw_ostream &OS) const override
Definition MCPError.cpp:30
std::error_code convertToErrorCode() const override
Definition MCPError.cpp:34