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

Don't swallow exceptions thrown in callbacks #27

Merged
merged 1 commit into from
Apr 22, 2017

Conversation

GAumala
Copy link
Contributor

@GAumala GAumala commented Apr 18, 2017

Do not execute callback function inside try catch block because it will
swallow the exception. New function safeReadDirSync only catches the
EACCES exception thrown by readdirSync.

I am using node-directory-tree to test a directory full of json files with jest. I want to make sure that they all have valid syntax and other properties. I do all my assertions inside the callback function. There I found a bug in which my assertion errors were not being reported by the test runner because of a try catch block swallowing them inside directory-tree.js. This PR fixes it and adds a test case.

Do not execute callback function inside try catch block because it will
swallow the exception. New function safeReadDirSync only catches the
EACCES exception thrown by readdirSync.
@GabrielDelepine
Copy link

Nice, I agree with your point of view

@mihneadb
Copy link
Owner

Nice find! Thanks for the PR!

@mihneadb mihneadb merged commit 74b3245 into mihneadb:master Apr 22, 2017
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.

3 participants