Skip to content

Commit

Permalink
Unify formatting error codes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Seelengrab committed Mar 4, 2024
1 parent 53b4b84 commit 6cce4a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/LanguageServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,6 +51,7 @@ const ERROR_CODES = (
CONTENT_MODIFIED,
SERVER_CANCELLED,
REQUEST_FAILED,
FORMATTING_FAILED,
NO_DOCUMENT,
MISMATCHED_VERSION,
SHUTDOWN_REQUEST
Expand Down
4 changes: 2 additions & 2 deletions src/requests/features.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit 6cce4a4

Please sign in to comment.