ensure parsing errors and 'lack of data' errors are passed back as exceptions
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 30 Aug 2011 10:22:31 +0000 (11:22 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 30 Aug 2011 10:22:31 +0000 (11:22 +0100)
src/jalview/io/packed/ParsePackedSet.java

index 97802f3..9a4af62 100644 (file)
@@ -8,6 +8,7 @@ import jalview.io.IdentifyFile;
 import jalview.io.packed.DataProvider.JvDataType;
 
 import java.io.BufferedReader;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
@@ -102,8 +103,13 @@ public class ParsePackedSet
           {
             br = new BufferedReader(src.getReader());
           }
-          context.updateSetModified(new jalview.io.AnnotationFile()
-                  .parseAnnotationFrom(context.getLastAlignment(), br));
+          if (new jalview.io.AnnotationFile()
+                  .parseAnnotationFrom(context.getLastAlignment(), br))
+          {
+            context.updateSetModified(true);
+          } else {
+            errmsg = "Annotation file contained no data.";
+          }
 
         } catch (Exception e)
         {
@@ -166,7 +172,20 @@ public class ParsePackedSet
         }
 
       }
-
+      if (exerror!=null)
+      {
+        if (errmsg!=null && errmsg.length()>0)
+        {
+          throw new IOException(errmsg,exerror);
+        } else {
+          throw new IOException(errmsg,exerror);
+        }
+      } else {
+      if (errmsg!=null && errmsg.length()>0)
+      {
+        throw new IOException(errmsg);
+      }
+      }
     }
     if (deuniquify)
     {