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

Check if file exists before trying to open it #16315

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

Thorium
Copy link
Contributor

@Thorium Thorium commented Nov 21, 2023

mkFirstLineOfFile is often called with non-existing temp-fsx script file, causing "file not found" exception,
then just to be caught by the try-with in the method.

Exceptions should happen on technical reasons, not as a part of a business workflow.

So it'd be better to check if file exists before trying to open it.

@Thorium Thorium requested a review from a team as a code owner November 21, 2023 09:25
@vzarytovskii vzarytovskii enabled auto-merge (squash) November 21, 2023 13:00
Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

Good stuff. Yeah we shouldn't use exception for the flow control. Thanks!

@vzarytovskii vzarytovskii merged commit 828755c into dotnet:main Nov 21, 2023
25 checks passed
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.

5 participants