Index: /trunk/ippToPsps/jython/batch.py
===================================================================
--- /trunk/ippToPsps/jython/batch.py	(revision 32210)
+++ /trunk/ippToPsps/jython/batch.py	(revision 32211)
@@ -47,5 +47,4 @@
         self.doc = doc
         self.fits = fits
-        if self.fits: self.header = self.fits.getPrimaryHeader()
 
         # set up logging
@@ -53,4 +52,9 @@
         self.logger.infoSeparator()
         self.logger.debug("Batch class constructor")
+
+        # check FITS file is ok - TODO could be neater
+        if self.fits: 
+            self.header = self.fits.getPrimaryHeader()
+            if not self.header: return
 
         # set up class variables
@@ -315,4 +319,5 @@
     @staticmethod
     def publishToDatastore(datastore, ippToPspsDb, batchID, batchName, subDir, tarballFile):
+
         if datastore.publish(batchName, subDir, tarballFile, "tgz"):
             ippToPspsDb.updateLoadedToDatastore(batchID, 1)
@@ -518,6 +523,10 @@
         self.createEmptyPspsTables()
         self.importIppTables()
-        if self.populatePspsTables():
-            if self.exportPspsTablesToFits():
+        if not self.populatePspsTables():
+            self.logger.errorPair("Aborting this batch", "unable to populate PSPS tables")
+        else:
+            if not self.exportPspsTablesToFits():
+                self.logger.errorPair("Aborting this batch", "unable to export tables to FITS file")
+            else:
                 self.writeBatchManifest()
                 if int(self.doc.find("options/publishToDatastore").text): self.tarZipAndpublishToDatastore()
