Author: thomasobrien95
Date: Tue Dec 16 11:54:16 2008
New Revision: 2887

Modified:
   trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java
   trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java

Log:
Fixed bug 1233. The full exception and stack trace was not being printed to the project file on save. Now the full exception with a stack trace is saved to the project file. This will aid in explaining broken project files.

Modified: trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java (original) +++ trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java Tue Dec 16 11:54:16 2008
@@ -1263,4 +1263,25 @@
             assertFalse(t.getIndices().contains(idx));
         }
     }
+
+    public void testSaveStoresExceptionInOutput() throws Exception {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+ SQLObject dbtreeRoot = (SQLObject) session.getSourceDatabases().getModel().getRoot();
+
+        SQLDatabase db = new SQLDatabase();
+        dbtreeRoot.addChild(db);
+
+        StubSQLObject sso = new StubSQLObject();
+        db.addChild(sso);
+
+        try {
+            project.save(out, ENCODING);
+ fail("No exception when trying to save unknown type of SQLObject");
+        } catch (UnsupportedOperationException ex) {
+            // expected result
+        }
+
+ assertTrue(out.toString().contains("UnsupportedOperationException"));
+        System.out.println(out.toString());
+    }
 }

Modified: trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java Tue Dec 16 11:54:16 2008
@@ -79,6 +79,7 @@
 import ca.sqlpower.architect.swingui.olap.VirtualCubePane;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.SPDataSource;
+import ca.sqlpower.util.ExceptionReport;
 import ca.sqlpower.util.SQLPowerUtils;
 import ca.sqlpower.xml.XMLHelper;

@@ -707,7 +708,15 @@
for (OLAPEditSession oSession : getSession().getOLAPEditSessions()) {
                 oSession.saveNotify();
             }
-
+        } catch (IOException e) {
+ ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_VERSION.toString(), "Architect").toXML());
+            throw e;
+        } catch (ArchitectException e) {
+ ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_VERSION.toString(), "Architect").toXML());
+            throw e;
+        } catch (RuntimeException e) {
+ ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_VERSION.toString(), "Architect").toXML());
+            throw e;
         } finally {
             if (out != null) out.close();
         }

Reply via email to