pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1687397 - /pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
Date Wed, 24 Jun 2015 23:13:35 GMT
Author: jahewson
Date: Wed Jun 24 23:13:34 2015
New Revision: 1687397

URL: http://svn.apache.org/r1687397
Log:
PDFBOX-2530: Handle uncaught exceptions

Modified:
    pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java

Modified: pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java?rev=1687397&r1=1687396&r2=1687397&view=diff
==============================================================================
--- pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java (original)
+++ pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/PDFDebugger.java Wed Jun 24 23:13:34
2015
@@ -43,6 +43,7 @@ import javax.swing.Action;
 import javax.swing.JComponent;
 import javax.swing.JMenu;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.KeyStroke;
@@ -639,8 +640,28 @@ public class PDFDebugger extends javax.s
     {
         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
         System.setProperty("apple.laf.useScreenMenuBar", "true");
+        
+        final PDFDebugger viewer = new PDFDebugger();
 
-        PDFDebugger viewer = new PDFDebugger();
+        // handle uncaught exceptions
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
+        {
+            @Override
+            public void uncaughtException(Thread thread, Throwable throwable)
+            {
+                StringBuilder sb = new StringBuilder();
+                sb.append(throwable.toString());
+                for (StackTraceElement element : throwable.getStackTrace())
+                {
+                    sb.append('\n');
+                    sb.append(element);
+                }
+                JOptionPane.showMessageDialog(viewer, "Error: " + sb.toString(),"Error",
+                                              JOptionPane.ERROR_MESSAGE);
+            }
+        });
+        
+        // open file, if any
         String filename = null;
         String password = "";
         



Mime
View raw message