|
| 1 | +// Copyright 2024 The Go Language Server Authors |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +package protocol |
| 5 | + |
| 6 | +// ErrorCodes predefined error codes. |
| 7 | +type ErrorCodes int32 |
| 8 | + |
| 9 | +const ( |
| 10 | + ParseErrorErrorCodes ErrorCodes = -32700 |
| 11 | + |
| 12 | + InvalidRequestErrorCodes ErrorCodes = -32600 |
| 13 | + |
| 14 | + MethodNotFoundErrorCodes ErrorCodes = -32601 |
| 15 | + |
| 16 | + InvalidParamsErrorCodes ErrorCodes = -32602 |
| 17 | + |
| 18 | + InternalErrorErrorCodes ErrorCodes = -32603 |
| 19 | + |
| 20 | + // ServerNotInitializedErrorCodes error code indicating that a server received a notification or request before the server has received the `initialize` request. |
| 21 | + ServerNotInitializedErrorCodes ErrorCodes = -32002 |
| 22 | + |
| 23 | + UnknownErrorCodeErrorCodes ErrorCodes = -32001 |
| 24 | +) |
| 25 | + |
| 26 | +type LSPErrorCodes int32 |
| 27 | + |
| 28 | +const ( |
| 29 | + // RequestFailedLSPErrorCodes a request failed but it was syntactically correct, e.g the method name was known and the parameters were valid. The error message should contain human readable information about why the request failed. |
| 30 | + // |
| 31 | + // @since 3.17.0 |
| 32 | + RequestFailedLSPErrorCodes LSPErrorCodes = -32803 |
| 33 | + |
| 34 | + // ServerCancelledLSPErrorCodes the server cancelled the request. This error code should only be used for requests that explicitly support being server cancellable. |
| 35 | + // |
| 36 | + // @since 3.17.0 |
| 37 | + ServerCancelledLSPErrorCodes LSPErrorCodes = -32802 |
| 38 | + |
| 39 | + // ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request. |
| 40 | + ContentModifiedLSPErrorCodes LSPErrorCodes = -32801 |
| 41 | + |
| 42 | + // RequestCancelledLSPErrorCodes the client has canceled a request and a server as detected the cancel. |
| 43 | + RequestCancelledLSPErrorCodes LSPErrorCodes = -32800 |
| 44 | +) |
| 45 | + |
| 46 | +type CancelParams struct { |
| 47 | + // ID the request id to cancel. |
| 48 | + ID CancelParamsID `json:"id"` |
| 49 | +} |
| 50 | + |
| 51 | +type ProgressParams struct { |
| 52 | + // Token the progress token provided by the client or server. |
| 53 | + Token ProgressToken `json:"token"` |
| 54 | + |
| 55 | + // Value the progress data. |
| 56 | + Value any `json:"value"` |
| 57 | +} |
0 commit comments