Debian Codegraph @

LspCpp/include/LibLsp/lsp/lsResponseError.h

raw
1 #pragma once
2
3 #include "LibLsp/JsonRpc/serializer.h"
4 #include <sstream>
5 #include "LibLsp/lsp/lsAny.h"
6
7 enum class lsErrorCodes : int32_t
8 {
9 // Defined by JSON RPC
10 ParseError = -32700,
11 InvalidRequest = -32600,
12 MethodNotFound = -32601,
13 InvalidParams = -32602,
14 InternalError = -32603,
15
16 /**
17 * This is the start range of JSON RPC reserved error codes.
18 * It doesn't denote a real error code. No LSP error codes should
19 * be defined between the start and end range. For backwards
20 * compatibility the `ServerNotInitialized` and the `UnknownErrorCode`
21 * are left in the range.
22 *
23 * @since 3.16.0
24 */
25 jsonrpcReservedErrorRangeStart = -32099,
26 /** @deprecated use jsonrpcReservedErrorRangeStart */
27 serverErrorStart = jsonrpcReservedErrorRangeStart,
28
29 /**
30 * This is the start range of JSON RPC reserved error codes.
31 * It doesn't denote a real error code.
32 *
33 * @since 3.16.0
34 */
35 jsonrpcReservedErrorRangeEnd = -32000,
36 /** @deprecated use jsonrpcReservedErrorRangeEnd */
37 serverErrorEnd = jsonrpcReservedErrorRangeEnd,
38
39 /**
40 * Error code indicating that a server received a notification or
41 * request before the server has received the `initialize` request.
42 */
43 ServerNotInitialized = -32002,
44 UnknownErrorCode = -32001,
45
46 /**
47 * This is the start range of LSP reserved error codes.
48 * It doesn't denote a real error code.
49 *
50 * @since 3.16.0
51 */
52 lspReservedErrorRangeStart = -32899,
53
54 /**
55 * The server cancelled the request. This error code should
56 * only be used for requests that explicitly support being
57 * server cancellable.
58 *
59 * @since 3.17.0
60 */
61 ServerCancelled = -32802,
62
63 /**
64 * The server detected that the content of a document got
65 * modified outside normal conditions. A server should
66 * NOT send this error code if it detects a content change
67 * in it unprocessed messages. The result even computed
68 * on an older state might still be useful for the client.
69 *
70 * If a client decides that a result is not of any use anymore
71 * the client should cancel the request.
72 */
73 ContentModified = -32801,
74
75 /**
76 * The client has canceled a request and a server as detected
77 * the cancel.
78 */
79 RequestCancelled = -32800,
80
81 /**
82 * This is the end range of LSP reserved error codes.
83 * It doesn't denote a real error code.
84 *
85 * @since 3.16.0
86 */
87 lspReservedErrorRangeEnd = -32800,
88 };
89 MAKE_REFLECT_TYPE_PROXY(lsErrorCodes);
90 struct lsResponseError
91 {
92 lsResponseError() : code(lsErrorCodes::UnknownErrorCode)
93 {
94 }
95
96 /**
97 * A number indicating the error type that occurred.
98 */
99 lsErrorCodes code;
100 // Short description.
101 /**
102 * A string providing a short description of the error.
103 */
104 std::string message;
105
106 /**
107 * A primitive or structured value that contains additional
108 * information about the error. Can be omitted.
109 */
110 optional<lsp::Any> data;
111 std::string ToString();
112 void Write(Writer& visitor);
113
114 MAKE_SWAP_METHOD(lsResponseError, code, message, data)
115 };
116 MAKE_REFLECT_STRUCT(lsResponseError, code, message, data)