Index: trunk/ppSub/src/ppSubThreshold.c
===================================================================
--- trunk/ppSub/src/ppSubThreshold.c	(revision 26899)
+++ trunk/ppSub/src/ppSubThreshold.c	(revision 26982)
@@ -45,5 +45,5 @@
     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS);                               // Random number generator
     if (!psImageBackground(stats, NULL, subImage, subMask, maskIgnore, rng)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to determine threshold.");
+        psError(PPSUB_ERR_DATA, false, "Unable to determine threshold.");
         psFree(rng);
         psFree(stats);
@@ -97,5 +97,5 @@
     pmReadout *in = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input image
     if (!in) {
-        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find readout.");
+        psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout.");
         return false;
     }
@@ -103,5 +103,5 @@
     pmReadout *ref = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference image
     if (!ref) {
-        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find readout.");
+        psError(PPSUB_ERR_UNKNOWN, false, "Unable to find readout.");
         return false;
     }
@@ -114,9 +114,9 @@
         psRegion *region = regItem->data.V; // Region of interest
         if (!lowThreshold(in, thresh, maskVal, maskThresh, region, "input convolved image")) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
+            psError(psErrorCodeLast(), false, "Unable to threshold input image.");
             return false;
         }
         if (!lowThreshold(ref, thresh, maskVal, maskThresh, region, "reference convolved image")) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to threshold input image.");
+            psError(psErrorCodeLast(), false, "Unable to threshold input image.");
             return false;
         }
