Skip to content

Conversation

@joyfulmantis
Copy link
Collaborator

No description provided.

@joyfulmantis joyfulmantis requested a review from isovector as a code owner July 8, 2023 21:28
Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a Note explaining our exception handling strategy? Then we can add to it as we go. Something like:

{- Note [Exception handling in plugins]
Plugins run in LspM, and so have access to IO. This means they are likely to throw exceptions, even if only by accident or through calling libraries that throw exceptions.
Ultimately, we're running a bunch of less-trusted IO code, so we should be robust to
it throwing.

We don't want these to bring down HLS. So we catch and log exceptions wherever we run
a handler defined in a plugin.

The flip side of this is that it's okay for plugins to throw exceptions as a way of signalling
failure!
-}

=> (SomeException -> PluginId -> T.Text)
-> String -- ^ label
=> (PluginId -> SMethod method -> SomeException -> T.Text)
-> SMethod method -- ^ label
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong comment

Just (Command _ innerCmdId innerArgs)
-> execCmd ide (ExecuteCommandParams Nothing innerCmdId innerArgs)
Nothing -> return $ Right $ InL A.Null
Nothing -> return $ Right $ InR Null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but I it's literally the same behaviour. The upstream spec is weird, I made an issue: microsoft/language-server-protocol#1766

= ideState
-> a
-> LspM Config (Either ResponseError Value)
-> LspM Config (Either ResponseError (Value |? Null))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, since they're represented the same, I'm not sure this really adds much except making things more complex for the users

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say less complex. LSP Types are used everywhere, and now command users don't need to use Aeson if they don't use it anywhere else (Pretty much every command returns null).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't matter too much, but I would hope that we can fix this upstream, and then we'd have to go back again...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Is there any reason why we can't use Aeson.Null for Null in lsp-types, perhaps by reexporting it instead of declaring our own? that would remove a source of name conflicts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay right, because it's only a constructor, not a type in its own right.

logWith recorder Warning (LogNoPluginForMethod $ Some m)
Just fs -> do
-- We run the notifications in order, so the core ghcide provider
-- (which restarts the shake process) hopefully comes last
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

@joyfulmantis joyfulmantis merged commit baf2fec into haskell:master Jul 11, 2023
@fendor fendor mentioned this pull request Aug 8, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants