diff options
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.h')
| -rw-r--r-- | clang-tools-extra/clangd/Protocol.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 7026d47b981..940c78f1d59 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -48,6 +48,23 @@ enum class ErrorCode { // Defined by the protocol. RequestCancelled = -32800, }; +// Models an LSP error as an llvm::Error. +class LSPError : public llvm::ErrorInfo<LSPError> { +public: + std::string Message; + ErrorCode Code; + static char ID; + + LSPError(std::string Message, ErrorCode Code) + : Message(std::move(Message)), Code(Code) {} + + void log(llvm::raw_ostream &OS) const override { + OS << int(Code) << ": " << Message; + } + std::error_code convertToErrorCode() const override { + return llvm::inconvertibleErrorCode(); + } +}; struct URIForFile { URIForFile() = default; |

