Skip to content

Conversation

tomsontom
Copy link
Contributor

fixes #2044

  • check if directory exists eg in workspaces a directory could have been delete since the last start
  • catch all errors while reading the directory content

…lipse-langium#2044)

- check if directory exists eg in workspaces a directory could have been delete since the last start
- catch all errors while reading the directory content
Copy link
Contributor

@sailingKieler sailingKieler left a comment

Choose a reason for hiding this comment

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

Thank you @tomsontom for taking the initiative about this! 🙏

I have an idea for an improvement, see below.

if( ! this.fileSystemProvider.existsSync(folderPath) ) {
console.info(`Directory ${folderPath} does not exist`);
return Promise.resolve();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about moving this diagnosis part into the catch block?, like

catch (e) {
    if(await this.fileSystemProvider.exists(folderPath) ) {
        console.error('Failure while reading directory content', e);
    } else {
        console.info(`Directory ${folderPath} does not exist`);
    }
}

Copy link
Member

@msujew msujew Oct 8, 2025

Choose a reason for hiding this comment

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

On that note: Please don't use the sync file system methods in framework code - there is no guarantee that every file system is actually capable of supporting sync file system requests.

To be honest, I don't even see a reason to actually call exists at all, since the e error object will contain the information what kind of error occurred.

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.

Language server does not initialize properly if workspace-folder does not exist (anymore)

3 participants