Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/main/java/com/itextpdf/rups/model/ErrorDialogPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This file is part of the iText (R) project.
import java.awt.Dimension;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Optional;

/**
* A utility to display a dialog showing Throwable object
Expand All @@ -71,7 +72,17 @@ public static void showErrorDialog(Component parent, Throwable th) {
private static String getTraceString(Throwable th) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw);
th.printStackTrace(pw);
Optional<Throwable> chuckIt = Optional.ofNullable(th);
chuckIt.map(Throwable::getLocalizedMessage)
.ifPresent(pw::println);
chuckIt.map(Throwable::getCause)
.map(Throwable::getLocalizedMessage)
.ifPresent(msg -> {
pw.print("Caused by: ");
pw.println(msg);
});
pw.append("[Stack Trace]\n");
chuckIt.ifPresent(throwable -> throwable.printStackTrace(pw));
return sw.toString();
}
}
10 changes: 8 additions & 2 deletions src/main/java/com/itextpdf/rups/model/ObjectLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This file is part of the iText (R) project.
*/
package com.itextpdf.rups.model;

import com.itextpdf.io.exceptions.IOException;
import com.itextpdf.rups.view.Language;

import javax.swing.SwingUtilities;
Expand Down Expand Up @@ -134,8 +135,13 @@ protected Void doInBackground() {
progress.setMessage(Language.XREF_READING.getString());
progress.setTotal(n);
});
while (objects.storeNextObject()) {
SwingUtilities.invokeLater(() -> progress.setValue(objects.getCurrent()));
try {
while (objects.storeNextObject()) {
SwingUtilities.invokeLater(() -> progress.setValue(objects.getCurrent()));
}
}
catch (IOException ioe) {
progress.showErrorDialog(ioe);
}
SwingUtilities.invokeLater(() -> progress.setTotal(0));
nodes = new TreeNodeFactory(objects);
Expand Down