Index: trunk/psphot/src/psphotImageLoop.c
===================================================================
--- trunk/psphot/src/psphotImageLoop.c	(revision 9566)
+++ trunk/psphot/src/psphotImageLoop.c	(revision 11263)
@@ -1,5 +1,6 @@
 # include "psphot.h"
 
-// XXX where do we load optional mask and weight input images?
+// XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error
+// XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit
 bool psphotImageLoop (pmConfig *config) {
 
@@ -11,5 +12,5 @@
     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
     if (!status) {
-	psError(PS_ERR_IO, false, "Can't find input data!");
+	psError(PSPHOT_ERR_PROG, false, "Can't find input data!");
 	return false;
     }
@@ -19,5 +20,5 @@
     // files associated with the science image
     if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-	psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");
+	psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
 	psFree(view);
 	return false;
@@ -28,5 +29,5 @@
         if (! chip->process || ! chip->file_exists) { continue; }
 	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-            psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);
+            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
 	    psFree (view);
 	    return false;
@@ -37,5 +38,5 @@
             if (! cell->process || ! cell->file_exists) { continue; }
 	    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-		psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
+		psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
 		psFree (view);
 		return false;
@@ -45,5 +46,5 @@
 	    while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
 		if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-		    psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
+		    psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
 		    psFree (view);
 		    return false;
@@ -54,5 +55,5 @@
 		// run the actual photometry analysis
 		if (!psphotReadout (config, view)) {
-		    psError(PS_ERR_UNKNOWN, false, "failed psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
+		    psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout);
 		    psFree (view);
 		    return false;
@@ -60,5 +61,5 @@
 
 		if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-		    psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
+		    psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);
 		    psFree (view);
 		    return false;
@@ -66,5 +67,5 @@
 	    }
 	    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-		psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
+		psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);
 		psFree (view);
 		return false;
@@ -72,5 +73,5 @@
 	}
 	if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-            psError(PS_ERR_UNKNOWN, false, "failed IO for chip %d in psphot\n", view->chip);
+            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
 	    psFree (view);
 	    return false;
@@ -78,5 +79,5 @@
     }
     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-	psError(PS_ERR_UNKNOWN, false, "failed IO for fpa in psphot\n");
+	psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
 	psFree (view);
 	return false;
