Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Catch README file not found error #1182

Merged
merged 1 commit into from
Apr 7, 2021
Merged

Conversation

sadick254
Copy link
Contributor

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

  • Use a fs.statSync to check if the file is available before calling fs.readFileSync

See atom/atom#22109

Alternate Designs

  • Add a try catch block around fs.readFileSync because the call to fs.readFileSync could throw an error in the event a file is not available.
try {
  readme = fs.readFileSync(this.readmePath, {encoding: 'utf8'})
} catch(err) {
  readme = null
}

Benefits

Improved user experience. We should not be throwing an error if the README file is not available, we should fail safely.

Possible Drawbacks

N/A

Applicable Issues

atom/atom#22109

@sadick254 sadick254 force-pushed the catch-readme-file-not-found branch from 22c2bd4 to 3a14ba4 Compare April 7, 2021 20:56
@sadick254 sadick254 merged commit 74a35d2 into master Apr 7, 2021
@sadick254 sadick254 deleted the catch-readme-file-not-found branch April 7, 2021 21:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant