@@ -43,53 +43,48 @@ private OpenDataLoaderPDF() {
4343 *
4444 * @param inputPdfName The path to the input PDF file.
4545 * @param config The configuration object specifying output formats and other options.
46- * @throws IOException If an error occurs during file reading or processing.
46+ *
4747 */
48- public static void processFile (String inputPdfName , Config config ) throws IOException {
49- if (!isValidInputFile (inputPdfName )) return ;
50-
51- DocumentProcessor .processFile (inputPdfName , config );
48+ public static void processFile (String inputPdfName , Config config ) {
49+ try {
50+ validateInputFile (inputPdfName );
51+ DocumentProcessor .processFile (inputPdfName , config );
52+ } catch (IllegalArgumentException | IOException ex ) {
53+ LOGGER .log (Level .WARNING , ex .getMessage ());
54+ }
5255 }
5356
5457 /**
5558 * Validates whether the given path refers to a valid PDF file.
5659 *
5760 * @param inputPdfName the path to the input file
58- * @return {@code true} if the path is non-null, points to an existing
59- * regular file, and has a .pdf extension; {@code false} otherwise
6061 */
61- private static boolean isValidInputFile (String inputPdfName ) {
62+ private static void validateInputFile (String inputPdfName ) {
6263
6364 if (inputPdfName == null || inputPdfName .isBlank ()) {
64- LOGGER .log (Level .WARNING , "Input file path is null or empty" );
65- return false ;
65+ throw new IllegalArgumentException ("Input PDF name is null or Empty" );
6666 }
6767
6868 final Path path ;
6969
7070 try {
7171 path = Paths .get (inputPdfName );
7272 } catch (InvalidPathException ex ) {
73- LOGGER .log (Level .WARNING , () -> "Invalid file path: " + inputPdfName );
74- return false ;
73+ throw new IllegalArgumentException ("Invalid Path: " + inputPdfName );
7574 }
7675
7776 if (!Files .exists (path )) {
78- LOGGER .log (Level .WARNING , () -> "File does not exist: " + inputPdfName );
79- return false ;
77+ throw new IllegalArgumentException ("File not fount at " + inputPdfName + " location" );
8078 }
8179
8280 if (!Files .isRegularFile (path )) {
83- LOGGER .log (Level .WARNING , () -> "Not a valid file: " + inputPdfName );
84- return false ;
81+ throw new IllegalArgumentException ("Not a valid file " + inputPdfName );
8582 }
8683
8784 if (!path .getFileName ().toString ().toLowerCase (Locale .ROOT ).endsWith (".pdf" )) {
88- LOGGER .log (Level .WARNING , () -> "Not a PDF file: " + inputPdfName );
89- return false ;
85+ throw new IllegalArgumentException ("Not a PDF file" );
9086 }
9187
92- return true ;
9388 }
9489
9590 /**
0 commit comments