Fix error handling in watcher. BUG= R=nweiz@google.com Review URL: https://codereview.chromium.org//23085006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart/pkg/watcher@26156 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkgs/watcher/lib/src/directory_watcher.dart b/pkgs/watcher/lib/src/directory_watcher.dart index eb948f5..16a5cf1 100644 --- a/pkgs/watcher/lib/src/directory_watcher.dart +++ b/pkgs/watcher/lib/src/directory_watcher.dart
@@ -134,18 +134,17 @@ if (entity is! File) return; _filesToProcess.add(entity.path); }, onError: (error) { - if (isDirectoryNotFoundException(error)) { - // If the directory doesn't exist, we end the listing normally, which - // has the desired effect of marking all files that were in the - // directory as being removed. - endListing(); - return; + if (!isDirectoryNotFoundException(error)) { + // It's some unknown error. Pipe it over to the event stream so the + // user can see it. + _events.addError(error); } - // It's some unknown error. Pipe it over to the event stream so we don't - // take down the whole isolate. - _events.addError(error); - }, onDone: endListing); + // When an error occurs, we end the listing normally, which has the + // desired effect of marking all files that were in the directory as + // being removed. + endListing(); + }, onDone: endListing, cancelOnError: true); } /// Processes [file] to determine if it has been modified since the last