Skip to content

Commit 48ea0e2

Browse files
committed
Add InvalidPathException handling on file open
When you open a PdfFile with an invalid path, it could cause an InvalidPathException instead of the NoSuchFileException, as it uses the newer toPath methods within PdfFile. In such cases there would be no feedback in the UI and just nothing would happen. Now it should behave like expected.
1 parent 4929dde commit 48ea0e2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/com/itextpdf/rups/controller/RupsInstanceController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ This file is part of the iText (R) project.
7272
import java.io.InputStream;
7373
import java.io.OutputStream;
7474
import java.nio.file.Files;
75+
import java.nio.file.InvalidPathException;
7576
import java.nio.file.NoSuchFileException;
7677
import java.util.function.Consumer;
7778
import javax.swing.JOptionPane;
@@ -196,8 +197,8 @@ public void loadFile(File file, boolean requireEditable) {
196197
readerController.getParser().setDocument(pdfFile.getPdfDocument());
197198
// At this point consider the file opened, so it can be added to MRU
198199
RupsConfiguration.INSTANCE.getMruListHandler().use(file);
199-
} catch (NoSuchFileException e) {
200-
final String msg = String.format(Language.ERROR_CANNOT_FIND_FILE.getString(), e.getFile());
200+
} catch (InvalidPathException | NoSuchFileException e) {
201+
final String msg = String.format(Language.ERROR_CANNOT_FIND_FILE.getString(), file);
201202
LoggerHelper.warn(msg, e, RupsInstanceController.class);
202203
Rups.showBriefMessage(msg);
203204
// Might as well remove file from MRU list, if it doesn't exist

0 commit comments

Comments
 (0)