Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1401] Present configuration read errors for the user #1406

Merged
merged 3 commits into from
Feb 15, 2023

Conversation

fabjan
Copy link
Contributor

@fabjan fabjan commented Nov 14, 2022

Description

If the the configuration file(s) found cannot be parsed, show a notice for the user instead of silently moving on to the next config alternative.

Fixes #1401

@fabjan
Copy link
Contributor Author

fabjan commented Nov 14, 2022

The notice in VS Code:

Skärmavbild 2022-11-14 kl  20 18 02

Example log message (I don't know why it shows up twice, that happens for me with any version of the language server):

Skärmavbild 2022-11-14 kl  20 18 15


-spec initialize(uri(), map(), map(), boolean()) -> ok.
initialize(RootUri, Capabilities, InitOptions, ReportMissingConfig) ->
-spec initialize(uri(), map(), map(), use_els_server | no_els_server) -> ok.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning for changing this parameter was that until I happened upon #1060 I thought the flag was only about verbosity or the config file missing. But after seeing that issue, it appears the purpose of the flag was to prevent els_server:send_notification from being called when the DAP script calls els_config:initialize/3.

(Perhaps els_config:initialize/3 can be removed completely and els_dap_general_provider.erl updated to call /4 with no_els_server).

Other names for the flag could maybe be no_notice | show_notice.

@fabjan
Copy link
Contributor Author

fabjan commented Feb 9, 2023

Feel free to close this PR if there is too much else going on. I prefer to not be the one closing it since it is not targeting my repository.

@robertoaloi
Copy link
Member

LGTM, but again the CI jobs seem to be expired and could not find a way to re-run them. If you can force-push, we can merge this one.

@fabjan
Copy link
Contributor Author

fabjan commented Feb 11, 2023

I rebased on main since I was going to force push and get another CI run anyway.

When doing a last minute test locally I found that a bad YAML yields a crash when merging the configs so I added a little syntax_error reason for the broken config reporting.

Skärmavbild 2023-02-11 kl  19 50 00

@@ -86,33 +86,46 @@
providers => map()
}.

-type error_reporting() :: lsp_notification | log.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I read through my changes again after some time away from it I came to the conclusion that no_els_server and use_els_server were kind of bad names for the variants. I think this is more clear.

Comment on lines 95 to +98
-spec initialize(uri(), map(), map()) -> ok.
initialize(RootUri, Capabilities, InitOptions) ->
initialize(RootUri, Capabilities, InitOptions, _ReportMissingConfig = false).
%% https://github.com/erlang-ls/erlang_ls/issues/1060
initialize(RootUri, Capabilities, InitOptions, _ErrorReporting = log).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

initialize/3 could be removed completely unless it is kept for some backwards compatibility I can't see.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a reason to keep it, either.

@fabjan
Copy link
Contributor Author

fabjan commented Feb 11, 2023

@robertoaloi I really didn't mean to spam when I commented the PRs can be closed. I just wanted to make sure they were not going to linger around making a mess!

I will touch them one by one now, so the other two will be "on hold" until this one is merged or closed.

Sorry for scope creeping a bit here after you already reviewed it, but I just changed the names of the error reporting selector variants and a little error handling for configs that are valid YAML but not maps (and thus can't be used at all) which I discovered when picking this back up, rebasing and testing locally.

@robertoaloi
Copy link
Member

@robertoaloi I really didn't mean to spam when I commented the PRs can be closed.

No problem at all, thanks for the call to action and for the contribution!

@robertoaloi robertoaloi merged commit f5398b2 into erlang-ls:main Feb 15, 2023
@robertoaloi
Copy link
Member

Thanks for the contribution!

@fabjan
Copy link
Contributor Author

fabjan commented Feb 15, 2023

Looks like the Windows CI failed because chocolatey could not install Erlang 22.3 :(

zengjinc pushed a commit to zengjinc/erlang_ls that referenced this pull request Jun 12, 2023
…ng-ls#1406)

* Present configuration read errors for the user

Fixes  erlang-ls#1401

* Clarify error_reporting flag in els_config

* Stop trying to merge config maps that are not maps
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.

erlang_ls should be more explicit when it finds an erlang_ls.config that isn't valid
2 participants