Index: trunk/psphot/src/psphotImageLoop.c
===================================================================
--- trunk/psphot/src/psphotImageLoop.c	(revision 15143)
+++ trunk/psphot/src/psphotImageLoop.c	(revision 15216)
@@ -1,3 +1,9 @@
 # include "psphotStandAlone.h"
+
+# define ESCAPE(MESSAGE) { \
+  psError(PSPHOT_ERR_DATA, false, MESSAGE); \
+  psFree (view); \
+  return false; \
+}
 
 bool psphotImageLoop (pmConfig *config) {
@@ -22,9 +28,5 @@
     
     // files associated with the science image
-    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-	psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
-	psFree(view);
-	return false;
-    }
+    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for fpa in psphot.");
 
     // for psphot, we force data to be read at the chip level 
@@ -38,15 +40,8 @@
 	pmFPAfileActivate (config->files, true, "PSPHOT.MASK");
 	pmFPAfileActivate (config->files, true, "PSPHOT.WEIGHT");
-	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
-	    psFree (view);
-	    return false;
-	}
+	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for Chip in psphot.");
 
 	// mosaic the cells of a chip into a single contiguous (trimmed) chip
-        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n");
-            return false;
-        }
+        if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) ESCAPE ("Unable to mosaic chip.");
 
 	// try to load other supporting data (PSF, SRC, etc).
@@ -56,9 +51,6 @@
 	pmFPAfileActivate (config->files, false, "PSPHOT.MASK");
 	pmFPAfileActivate (config->files, false, "PSPHOT.WEIGHT");
-	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
-            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
-	    psFree (view);
-	    return false;
-	}
+	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for Chip in psphot.");
+
 	// re-activate files so they will be closed and freed below
 	pmFPAfileActivate (config->files, true, NULL);
@@ -83,21 +75,13 @@
 
 	// save output which is saved at the chip level
-	if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip);
-	    psFree (view);
-	    return false;
-	}
+	if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed output for Chip in psphot.");
     }
     // save output which is saved at the fpa level
-    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
-	psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n");
-	psFree (view);
-	return false;
-    }
+    if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed ouput for FPA in psphot.");
+
+    // fail if we failed to handle an error
+    if (psErrorCodeLast() != PS_ERR_NONE) psAbort ("failed to handle an error!");
 
     psFree (view);
-
-    // fail if we failed to handle an error
-    if (psErrorCodeLast() != PS_ERR_NONE) return false;
     return true;
 }
