Updates for 0.9.5
[debian/openrocket] / src / net / sf / openrocket / file / RocketLoader.java
index 13f888ca18e0ec999f4fef001636ffffbf5c5cb3..113bc690eb74f48e316a36eda28aaa7ad69ac6dc 100644 (file)
@@ -14,17 +14,29 @@ import net.sf.openrocket.document.OpenRocketDocument;
 public abstract class RocketLoader {
        protected final WarningSet warnings = new WarningSet();
 
-
+       
        /**
         * Loads a rocket from the specified File object.
         */
        public final OpenRocketDocument load(File source) throws RocketLoadException {
                warnings.clear();
+               InputStream stream = null;
 
                try {
-                       return load(new BufferedInputStream(new FileInputStream(source)));
+                       
+                       stream = new BufferedInputStream(new FileInputStream(source));
+                       return load(stream);
+                       
                } catch (FileNotFoundException e) {
                        throw new RocketLoadException("File not found: " + source);
+               } finally {
+                       if (stream != null) {
+                               try {
+                                       stream.close();
+                               } catch (IOException e) {
+                                       e.printStackTrace();
+                               }
+                       }
                }
        }
 
@@ -40,11 +52,6 @@ public abstract class RocketLoader {
                        throw e;
                } catch (IOException e) {
                        throw new RocketLoadException("I/O error: " + e.getMessage());
-               } catch (Exception e) {
-                       throw new RocketLoadException("An unknown error occurred.  Please report a bug.", e);
-               } catch (Throwable e) {
-                       throw new RocketLoadException("A serious error occurred and the software may be "
-                                       + "unstable.  Save your designs and restart OpenRocket.", e);
                }
        }