Skip to content

Commit 949722d

Browse files
committed
Add logic to handle silent failures when using process readers
1 parent e5e1b33 commit 949722d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/com/github/stickerifier/stickerify/process/ProcessHelper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.slf4j.event.Level;
88

99
import java.io.IOException;
10+
import java.io.UncheckedIOException;
1011
import java.util.StringJoiner;
1112
import java.util.concurrent.Semaphore;
1213
import java.util.concurrent.TimeUnit;
@@ -40,17 +41,17 @@ public static String executeCommand(final String... command) throws ProcessExcep
4041
var outputThread = Thread.ofVirtual().start(() -> {
4142
try (var reader = process.inputReader(UTF_8)) {
4243
reader.lines().forEach(standardOutput::add);
43-
} catch (IOException e) {
44-
LOGGER.at(Level.ERROR).setCause(e).log("Error while closing process output reader");
44+
} catch (IOException | UncheckedIOException e) {
45+
LOGGER.at(Level.ERROR).setCause(e).log("An error occurred using process output reader");
4546
}
4647
});
4748

4849
var standardError = new StringJoiner("\n");
4950
var errorThread = Thread.ofVirtual().start(() -> {
5051
try (var reader = process.errorReader(UTF_8)) {
5152
reader.lines().forEach(standardError::add);
52-
} catch (IOException e) {
53-
LOGGER.at(Level.ERROR).setCause(e).log("Error while closing process error reader");
53+
} catch (IOException | UncheckedIOException e) {
54+
LOGGER.at(Level.ERROR).setCause(e).log("An error occurred using process error reader");
5455
}
5556
});
5657

0 commit comments

Comments
 (0)