File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
lsp-types/src/Language/LSP/Protocol/Message Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,21 @@ data ResponseError =
57
57
, _xdata :: Maybe Value
58
58
} deriving stock (Show , Eq , Generic )
59
59
60
+ {- Note [ErrorCodes and LSPErrorCodes]
61
+
62
+ Confusingly, the metamodel defines _two_ enums for error codes. One of
63
+ these covers JSON RPC errors and one covers LSP-specific errors. We want
64
+ to accept either, mostly so we can make use of the pre-specified enum values.
65
+
66
+ However, _both_ of them are listed as accepting custom values. This means
67
+ that `LSPErrorCodes |? ErrorCodes` isn't quite right: when we parse it from
68
+ JSON, if we get an error code that isn't a known value of `LSPErrorCodes`, we
69
+ will just use the custom value constructor, without trying `ErrorCodes`.
70
+
71
+ It's hard to find any other good way of representing things properly with what
72
+ we've got, so in the end we decided to patch up the JSON parsing with a custom
73
+ instance.
74
+ -}
60
75
deriveToJSON lspOptions ''ResponseError
61
76
instance FromJSON ResponseError where
62
77
parseJSON =
You can’t perform that action at this time.
0 commit comments