Skip to content

Commit d0e3535

Browse files
committed
Also allowing the url and urlLabel to be configured in the DAPError.
1 parent b437151 commit d0e3535

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

lldb/tools/lldb-dap/DAPError.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ namespace lldb_dap {
1414

1515
char DAPError::ID;
1616

17-
DAPError::DAPError(std::string message, bool show_user)
18-
: m_message(message), m_show_user(show_user) {}
17+
DAPError::DAPError(std::string message, std::error_code EC, bool show_user,
18+
std::optional<std::string> url,
19+
std::optional<std::string> url_label)
20+
: m_message(message), m_ec(EC), m_show_user(show_user), m_url(url),
21+
m_url_label(url_label) {}
1922

2023
void DAPError::log(llvm::raw_ostream &OS) const { OS << m_message; }
2124

lldb/tools/lldb-dap/DAPError.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Support/Error.h"
10+
#include <optional>
1011
#include <string>
12+
#include <system_error>
1113

1214
namespace lldb_dap {
1315

@@ -17,17 +19,25 @@ class DAPError : public llvm::ErrorInfo<DAPError> {
1719
public:
1820
static char ID;
1921

20-
DAPError(std::string message, bool show_user = false);
22+
DAPError(std::string message,
23+
std::error_code EC = llvm::inconvertibleErrorCode(),
24+
bool show_user = true, std::optional<std::string> url = std::nullopt,
25+
std::optional<std::string> url_label = std::nullopt);
2126

2227
void log(llvm::raw_ostream &OS) const override;
2328
std::error_code convertToErrorCode() const override;
2429

2530
const std::string &getMessage() const { return m_message; }
2631
bool getShowUser() const { return m_show_user; }
32+
const std::optional<std::string> &getURL() const { return m_url; }
33+
const std::optional<std::string> &getURLLabel() const { return m_url; }
2734

2835
private:
2936
std::string m_message;
37+
std::error_code m_ec;
3038
bool m_show_user;
39+
std::optional<std::string> m_url;
40+
std::optional<std::string> m_url_label;
3141
};
3242

3343
} // namespace lldb_dap

lldb/tools/lldb-dap/Handler/RequestHandler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ class RequestHandler : public BaseRequestHandler {
143143
error_message.format = E.getMessage();
144144
error_message.showUser = E.getShowUser();
145145
error_message.id = E.convertToErrorCode().value();
146-
// TODO: We could add url/urlLabel to the error message for more
147-
// information for users.
146+
error_message.url = E.getURL();
147+
error_message.urlLabel = E.getURLLabel();
148148
return llvm::Error::success();
149149
}))
150150
error_message.format = llvm::toString(std::move(unhandled));

0 commit comments

Comments
 (0)