haskell / haskell/haskell-language-server
Exceptions thrown in `Action` should be logged, not turned into diagnostics
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 12
Description
At the moment if an exception is thrown in an `Action` it is usually caught here: https://github.com/haskell/haskell-language-server/blob/master/ghcide/src/Development/IDE/Core/Shake.hs#L1169
This takes the caught exception and puts it into a _diagnostic_ for the current file. My issue with this is that LSP diagnostics are for _issues with the user's code_, not for _issues with HLS_, and exceptions from `Action`s are more likely to be the latter than the former.
The exception (and the reason why we do this, according to @wz1000 ) is that the GHC API will throw sometimes, and that often does indicate a user problem that we want to show as a diagnostic. But we can handle this by explicitly catching exceptions in e.g. the `TypeCheck` rule. That seems cleaner than imposing this on everyone.
My proposal:
- Switch that line to log at error instead of adding a diagnostic
- Add explicit catches to the rules that call the GHC API
Note that the current situation sucks up exceptions from all of the following:
- Exceptions thrown by our code
- Exceptions thrown by libraries that we call into (e.g. hlint)
- Use of the `MonadFail Action` instance, which throws exceptions
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.