-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fs.existsSync should not throw and catch an exception in the implementation #8731
Comments
@MetaMemoryT could you provide a code sample to clarify what you would like to happen? It's pretty common for node to throw on bad inputs. It's even more common to throw in synchronous methods. |
The current implementation looks like this:
It would be nice if it looked like this:
and then a new ffi method was created, binding.existsSync that would not internally throw and catch a javascript exception. This would improve performance also, if it was implemented properly. @cjihrig this is not a matter of throwing an exception on bad inputs, any path is a good input, the goal of this function is to return a Boolean representing whether or not the path exists. Throwing an exception is redundant, as it is representing the same information that this particular function is returning (a Boolean false value). |
Hmm... is there a way to do that with node.js cli? |
with https://www.npmjs.org/package/node-inspector you can. |
@MetaMemoryT ah, you're referring to
This can probably be closed. |
Oops, thanks. |
fs.execSync should be implemented in a manner that does not require throwing and catching an exception. Often while debugging a useful strategy is to break on all exceptions when searching for a problem. Having this function throw an exception just means more noise to wade through.
The text was updated successfully, but these errors were encountered: