Index: trunk/psModules/src/camera/pmFPAConstruct.c
===================================================================
--- trunk/psModules/src/camera/pmFPAConstruct.c	(revision 7278)
+++ trunk/psModules/src/camera/pmFPAConstruct.c	(revision 7311)
@@ -26,6 +26,6 @@
     bool status = true;                 // Result of MD lookup
     psMetadata *cells = psMetadataLookupMD(&status, format, "CELLS"); // The CELLS
-    if (! status) {
-        psError(PS_ERR_IO, false, "Unable to determine CELLS of camera.\n");
+    if (!status || !cells) {
+        psError(PS_ERR_IO, true, "Unable to determine CELLS of camera.\n");
         return NULL;
     }
@@ -114,6 +114,6 @@
     }
     psMetadataItem *resultItem = psMetadataLookup(header, keyword);
-    if (! resultItem) {
-        psError(PS_ERR_IO, false, "Unable to find %s in primary header to identify %s.\n", keyword, name);
+    if (!resultItem) {
+        psError(PS_ERR_IO, true, "Unable to find %s in primary header to identify %s.\n", keyword, name);
         return NULL;
     }
@@ -138,5 +138,8 @@
     fpa->hdu = psMemIncrRefCounter(hdu);
     if (hdu->header) {
-        pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL);
+        if (!pmConceptsReadFPA(fpa, PM_CONCEPT_SOURCE_HEADER, NULL)) {
+            psError(PS_ERR_UNKNOWN, false, "Failed to read concepts for FPA");
+            return false;
+        }
     }
     pmFPASetFileStatus(fpa, true);
@@ -256,5 +259,8 @@
 
     if (hdu && level == PM_FPA_LEVEL_FPA) {
-        addHDUtoFPA(fpa, hdu);
+        if (!addHDUtoFPA(fpa, hdu)) {
+            psError(PS_ERR_UNKNOWN, false, "Adding HDU to FPA (%s)", contents);
+            return -1;
+        }
     }
 
@@ -333,5 +339,8 @@
         }
         newCell->config = psMemIncrRefCounter(cellData);
-        pmConceptsReadCell(newCell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, false, NULL);
+        if (!pmConceptsReadCell(newCell, PM_CONCEPT_SOURCE_CAMERA | PM_CONCEPT_SOURCE_DEFAULTS, false, NULL)) {
+            psError(PS_ERR_IO, false, "Reading concepts for cell %d", numCells);
+            return -1;
+        }
         numCells++;
     }
@@ -388,4 +397,9 @@
     bool mdok = true;                   // Status from MD lookups
     psMetadata *components = psMetadataLookupMD(&mdok, camera, "FPA"); // FPA components
+    if (!mdok || !components) {
+        psError(PS_ERR_IO, true, "Failed to lookup \"FPA\"");
+        psFree(fpa);
+        return NULL;
+    }
     psMetadataIterator *componentsIter = psMetadataIteratorAlloc(components, PS_LIST_HEAD, NULL);
     psMetadataItem *componentsItem = NULL; // Item from components
@@ -500,5 +514,11 @@
         hdu->format = psMemIncrRefCounter(format);
         const char *content = contentsItem->data.V; // The content data
-        processContents(fpa, chip, cell, hdu, level, content, format);
+        if (processContents(fpa, chip, cell, hdu, level, content, format) < 0) {
+            psError(PS_ERR_IO, false, "Error setting contents for %s", contentsItem->name);
+            psFree(hdu);
+            psFree(contentsIter);
+
+            return false;
+        }
         psFree(hdu);
     }
@@ -568,9 +588,17 @@
         if (!mdok || !contents || strlen(contents) == 0) {
             psError(PS_ERR_IO, true, "Unable to find CONTENTS in the camera format configuration.\n");
+            psFree(phdu);
             psFree(view);
             return NULL;
         }
 
-        processContents(fpa, NULL, NULL, phdu, PM_FPA_LEVEL_FPA, contents, format);
+        if (processContents(fpa, NULL, NULL, phdu, PM_FPA_LEVEL_FPA, contents, format) < 0) {
+            psError(PS_ERR_IO, false, "Error setting CONTENTS");
+            psFree(phdu);
+            psFree(view);
+
+            return NULL;
+        }
+
         psFree(phdu);
         return view;
@@ -581,5 +609,14 @@
     psMetadata *contents = psMetadataLookupMD(&mdok, format, "CONTENTS"); // The contents of the FITS file
     if (!mdok || !contents) {
-        psError(PS_ERR_IO, false, "Unable to find CONTENTS in the camera format configuration.\n");
+        if (mdok && !contents) {
+            psError(PS_ERR_IO, true, "CONTENTS metadata is NULL in the camera format configuration.");
+        } else {
+            if(psMetadataLookup(format, "CONTENTS") != NULL) {
+                psError(PS_ERR_IO, true, "CONTENTS is of wrong type in camera format configuration");
+            } else {
+                psError(PS_ERR_IO, true, "Unable to find CONTENTS in the camera format configuration.");
+            }
+        }
+
         psFree(view);
         return NULL;
