Index: trunk/ppStack/src/ppStackConvolve.c
===================================================================
--- trunk/ppStack/src/ppStackConvolve.c	(revision 26898)
+++ trunk/ppStack/src/ppStackConvolve.c	(revision 27004)
@@ -82,5 +82,5 @@
         } else if (options->numCols != readout->image->numCols ||
                    options->numRows != readout->image->numRows) {
-            psError(PS_ERR_UNKNOWN, true, "Sizes of input images don't match: %dx%d vs %dx%d",
+            psError(PPSTACK_ERR_ARGUMENTS, true, "Sizes of input images don't match: %dx%d vs %dx%d",
                     readout->image->numCols, readout->image->numRows, options->numCols, options->numRows);
             psFree(rng);
@@ -94,9 +94,23 @@
         options->origCovars->data[i] = psMemIncrRefCounter(readout->covariance);
         if (!ppStackMatch(readout, options, i, config)) {
-	    // XXX many things can cause a failure of ppStackMatch -- should some be handled differently? 
-            psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
-            options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH;
-            psErrorClear();
-            continue;
+            // XXX many things can cause a failure of ppStackMatch -- should some be handled differently?
+            psErrorCode error = psErrorCodeLast(); // Error code
+            switch (error) {
+                // Fatal errors
+              case PM_ERR_CONFIG:
+              case PPSTACK_ERR_CONFIG:
+              case PPSTACK_ERR_IO:
+                psError(error, false, "Unable to match image %d due to fatal error.", i);
+                return false;
+                // Non-fatal errors
+              case PM_ERR_STAMPS:
+              case PM_ERR_SMALL_AREA:
+              case PPSTACK_ERR_DATA:
+              default:
+                psErrorStackPrint(stderr, "Unable to match image %d --- ignoring.", i);
+                options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH;
+                psErrorClear();
+                continue;
+            }
         }
         options->convCovars->data[i] = psMemIncrRefCounter(readout->covariance);
@@ -136,5 +150,5 @@
         assert(hdu);
         if (!ppStackWriteImage(options->convImages->data[i], hdu->header, readout->image, config)) {
-            psError(PS_ERR_IO, false, "Unable to write convolved image %d", i);
+            psError(PPSTACK_ERR_IO, false, "Unable to write convolved image %d", i);
             psFree(fpaList);
             psFree(cellList);
@@ -145,5 +159,5 @@
         pmConfigMaskWriteHeader(config, maskHeader);
         if (!ppStackWriteImage(options->convMasks->data[i], maskHeader, readout->mask, config)) {
-            psError(PS_ERR_IO, false, "Unable to write convolved mask %d", i);
+            psError(PPSTACK_ERR_IO, false, "Unable to write convolved mask %d", i);
             psFree(fpaList);
             psFree(cellList);
@@ -154,5 +168,5 @@
         psFree(maskHeader);
         if (!ppStackWriteImage(options->convVariances->data[i], hdu->header, readout->variance, config)) {
-            psError(PS_ERR_IO, false, "Unable to write convolved variance %d", i);
+            psError(PPSTACK_ERR_IO, false, "Unable to write convolved variance %d", i);
             psFree(fpaList);
             psFree(cellList);
@@ -208,5 +222,5 @@
 
     if (numGood == 0) {
-        psError(PS_ERR_UNKNOWN, false, "No good images to combine.");
+        psError(PPSTACK_ERR_REJECTED, false, "No good images to combine.");
         psFree(fpaList);
         psFree(cellList);
@@ -257,5 +271,5 @@
         assert(values->n == numGood);
         if (!psVectorSortInPlace(values)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to sort vector.");
+            psError(PPSTACK_ERR_PROG, false, "Unable to sort vector.");
             psFree(values);
             return false;
@@ -295,5 +309,5 @@
 
     if (numGood == 0) {
-        psError(PS_ERR_UNKNOWN, false, "No good images to combine.");
+        psError(PPSTACK_ERR_REJECTED, false, "No good images to combine.");
         return false;
     }
