Skip to content

Commit

Permalink
fix: Report exception if filewatcher fails to start (#17161)
Browse files Browse the repository at this point in the history
Related to #17159
  • Loading branch information
Artur- committed Jul 3, 2023
1 parent 8c12e1d commit cadef8c
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;

import io.methvin.watcher.DirectoryWatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.vaadin.flow.function.SerializableConsumer;

Expand Down Expand Up @@ -61,7 +62,10 @@ public FileWatcher(SerializableConsumer<File> onChangeConsumer,
* Starts the file watching.
*/
public void start() {
watcher.watchAsync();
watcher.watchAsync().exceptionally((e) -> {
getLogger().error("Error starting file watcher", e);
return null;
});
}

/**
Expand All @@ -74,4 +78,8 @@ public void stop() throws IOException {
watcher.close();
}

private static Logger getLogger() {
return LoggerFactory.getLogger(FileWatcher.class);
}

}

0 comments on commit cadef8c

Please sign in to comment.