stop execution after errors #17

Closed
MaThGo opened this Issue Feb 17, 2013 · 0 comments

2 participants

@MaThGo

When you take a look at L88 you'll see that code execution doesn't stop after an error.

If you now, for example, pass a non-existing path to the find function there is an error event triggered. As long as you simply throw the error there is no problem since that stops the execution immediatly.

var finder = findit.find('/non/existing/path');
finder.on('error', function (error) {
  throw error;
});
    throw err;
          ^
Error: ENOENT, lstat './libs'

As soon as you dont throw it, for example if you want to handle it in another way
execution runs on and the code tries to execute s.isDirectory() but since s is undefined at that point a TypeError is thrown.

var finder = findit.find('/non/existing/path');

finder.on('error', function (error) {
  handleError(error);
});
        if (s.isDirectory()) {
              ^
TypeError: Cannot call method 'isDirectory' of undefined
@substack substack closed this Sep 14, 2013
@substack substack closed this Sep 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment