Skip to content

Commit

Permalink
Improved exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mackdk committed May 8, 2024
1 parent 0f181e8 commit b338893
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/com/suse/matcher/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.apache.logging.log4j.core.LoggerContext;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -28,9 +30,8 @@ public class Main {
* The main method.
*
* @param args command line arguments
* @throws Exception if anything unexpected happens
*/
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
long start = System.currentTimeMillis();
CommandLine commandLine = parseCommandLine(args);

Expand Down Expand Up @@ -68,8 +69,13 @@ public static void main(String[] args) throws Exception {

logger.info("Whole execution took {}ms", System.currentTimeMillis() - start);
}
catch (Exception ex) {
logger.error("Unexpected exception: ", ex);
catch (IOException ex) {
logger.error("Unexpected I/O error", ex);
throw new UncheckedIOException(ex);
}
catch (RuntimeException ex) {
logger.error("Unexpected error", ex);
throw ex;
}
}
}
Expand Down

0 comments on commit b338893

Please sign in to comment.