Skip to content

Commit 96ae6f0

Browse files
committed
Added michaelpj's note
1 parent 1be5f17 commit 96ae6f0

File tree

1 file changed

+15
-0
lines changed
  • lsp-types/src/Language/LSP/Protocol/Message

1 file changed

+15
-0
lines changed

lsp-types/src/Language/LSP/Protocol/Message/Types.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ data ResponseError =
5757
, _xdata :: Maybe Value
5858
} deriving stock (Show, Eq, Generic)
5959

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+
-}
6075
deriveToJSON lspOptions ''ResponseError
6176
instance FromJSON ResponseError where
6277
parseJSON =

0 commit comments

Comments
 (0)