1//===-- DAPError.h --------------------------------------------------------===//
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_TOOLS_LLDB_DAP_DAPERROR_H
10#define LLDB_TOOLS_LLDB_DAP_DAPERROR_H
11
12#include "llvm/Support/Error.h"
13#include <optional>
14#include <string>
15#include <system_error>
16
17namespace lldb_dap {
18
19/// An error that is reported as a DAP Error Message, which may be presented to
20/// the user.
21class DAPError : public llvm::ErrorInfo<DAPError> {
22public:
23 static char ID;
24
25 DAPError(std::string message,
26 std::error_code EC = llvm::inconvertibleErrorCode(),
27 bool show_user = true, std::optional<std::string> url = std::nullopt,
28 std::optional<std::string> url_label = std::nullopt);
29
30 void log(llvm::raw_ostream &OS) const override;
31 std::error_code convertToErrorCode() const override;
32
33 const std::string &getMessage() const { return m_message; }
34 bool getShowUser() const { return m_show_user; }
35 const std::optional<std::string> &getURL() const { return m_url; }
36 const std::optional<std::string> &getURLLabel() const { return m_url_label; }
37
38private:
39 std::string m_message;
40 std::error_code m_ec;
41 bool m_show_user;
42 std::optional<std::string> m_url;
43 std::optional<std::string> m_url_label;
44};
45
46/// An error that indicates the current request handler cannot execute because
47/// the process is not stopped.
48class NotStoppedError : public llvm::ErrorInfo<NotStoppedError> {
49public:
50 static char ID;
51 void log(llvm::raw_ostream &OS) const override;
52 std::error_code convertToErrorCode() const override;
53};
54
55} // namespace lldb_dap
56
57#endif // LLDB_TOOLS_LLDB_DAP_DAPERROR_H
58

source code of lldb/tools/lldb-dap/DAPError.h