Index: trunk/ppSub/src/ppSubLoop.c
===================================================================
--- trunk/ppSub/src/ppSubLoop.c	(revision 26899)
+++ trunk/ppSub/src/ppSubLoop.c	(revision 26982)
@@ -43,10 +43,10 @@
 
     if (!ppSubSetMasks(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to set masks.");
+        psError(psErrorCodeLast(), false, "Unable to set masks.");
         return false;
     }
 
     if (!ppSubMatchPSFs(data)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to match PSFs.");
+        psError(psErrorCodeLast(), false, "Unable to match PSFs.");
         return false;
     }
@@ -57,5 +57,5 @@
     // generate the residual stamp grid for visualization
     if (!ppSubResidualSampleJpeg(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to update.");
+        psError(psErrorCodeLast(), false, "Unable to update.");
         return false;
     }
@@ -71,5 +71,5 @@
 
     if (!ppSubLowThreshold(data)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to threshold images.");
+        psError(psErrorCodeLast(), false, "Unable to threshold images.");
         return false;
     }
@@ -82,15 +82,15 @@
 
     if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to define output.");
+        psError(psErrorCodeLast(), false, "Unable to define output.");
         return false;
     }
 
     if (!data->quality && !ppSubMakePSF(data)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF.");
+        psError(psErrorCodeLast(), false, "Unable to generate PSF.");
         return false;
     }
 
     if (!ppSubReadoutSubtract(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to subtract images.");
+        psError(psErrorCodeLast(), false, "Unable to subtract images.");
         return false;
     }
@@ -104,5 +104,5 @@
     // Higher order background subtraction using psphot
     if (!ppSubBackground(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to subtract background.");
+        psError(psErrorCodeLast(), false, "Unable to subtract background.");
         return false;
     }
@@ -110,5 +110,5 @@
     // Perform Variance correction (rescale within a modest range)
     if (!ppSubVarianceRescale(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to rescale variance.");
+        psError(psErrorCodeLast(), false, "Unable to rescale variance.");
         return false;
     }
@@ -120,5 +120,5 @@
 
     if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry.");
+        psError(psErrorCodeLast(), false, "Unable to perform photometry.");
         return false;
     }
@@ -131,5 +131,5 @@
     // Perform statistics on the cell
     if (!ppSubReadoutStats(data)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to collect statistics");
+        psError(psErrorCodeLast(), false, "Unable to collect statistics");
         return false;
     }
@@ -137,5 +137,5 @@
     // generate the binned image used to write the jpeg
     if (!ppSubReadoutJpeg(config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to update.");
+        psError(psErrorCodeLast(), false, "Unable to update.");
         return false;
     }
@@ -149,10 +149,10 @@
 
         if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to define inverse.");
+            psError(psErrorCodeLast(), false, "Unable to define inverse.");
             return false;
         }
 
         if (!ppSubReadoutInverse(config)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to invert images.");
+            psError(psErrorCodeLast(), false, "Unable to invert images.");
             return false;
         }
@@ -170,5 +170,5 @@
 
         if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry.");
+            psError(psErrorCodeLast(), false, "Unable to perform photometry.");
             return false;
         }
