From 6cce4a48e5a2386a3a65efa6927521c476572d89 Mon Sep 17 00:00:00 2001 From: Sukera Date: Mon, 4 Mar 2024 12:16:30 +0100 Subject: [PATCH] Unify formatting error codes Since this is basically the same errors, unify the two error codes into one. Technically the two are subtly different (one is trying to format the whole document, while the other is only trying to format a section), but the underlying cause is likely the same, so it's fine to merge them. If necessary/required, they can be disentangled later on too, as currently noone seems to check them anyway. --- src/LanguageServer.jl | 2 ++ src/requests/features.jl | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LanguageServer.jl b/src/LanguageServer.jl index a7a4361b..f9a35a30 100644 --- a/src/LanguageServer.jl +++ b/src/LanguageServer.jl @@ -41,6 +41,7 @@ const SERVER_CANCELLED = -32802 const REQUEST_FAILED = -32803 # Specific to our implementation +const FORMATTING_FAILED = -33000 const NO_DOCUMENT = -33100 const MISMATCHED_VERSION = -33101 const SHUTDOWN_REQUEST = -32600 @@ -50,6 +51,7 @@ const ERROR_CODES = ( CONTENT_MODIFIED, SERVER_CANCELLED, REQUEST_FAILED, + FORMATTING_FAILED, NO_DOCUMENT, MISMATCHED_VERSION, SHUTDOWN_REQUEST diff --git a/src/requests/features.jl b/src/requests/features.jl index 9d232b64..0652ec57 100644 --- a/src/requests/features.jl +++ b/src/requests/features.jl @@ -160,7 +160,7 @@ function textDocument_formatting_request(params::DocumentFormattingParams, serve format_text(get_text(doc), params, config) catch err return JSONRPC.JSONRPCError( - -32000, + FORMATTING_FAILED, "Failed to format document: $err.", nothing ) @@ -210,7 +210,7 @@ function textDocument_range_formatting_request(params::DocumentRangeFormattingPa format_text(text_marked, params, config) catch err return JSONRPC.JSONRPCError( - -33000, + FORMATTING_FAILED, "Failed to format document: $err.", nothing )