Index: trunk/psModules/src/imcombine/pmSubtractionEquation.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 26893)
+++ trunk/psModules/src/imcombine/pmSubtractionEquation.c	(revision 27086)
@@ -7,4 +7,5 @@
 #include <pslib.h>
 
+#include "pmErrorCodes.h"
 #include "pmSubtraction.h"
 #include "pmSubtractionKernels.h"
@@ -718,5 +719,5 @@
     // Generate convolutions: these are generated once and saved
     if (!pmSubtractionConvolveStamp(stamp, kernels, footprint)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to convolve stamp %d.", index);
+        psError(psErrorCodeLast(), false, "Unable to convolve stamp %d.", index);
         return NULL;
     }
@@ -869,5 +870,5 @@
 
     if (!psThreadPoolWait(true)) {
-        psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
+        psError(psErrorCodeLast(), false, "Error waiting for threads.");
         return false;
     }
@@ -989,5 +990,5 @@
             psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm
             if (!psVectorStats(stats, norms, NULL, NULL, 0)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to determine median normalisation");
+                psError(PM_ERR_DATA, false, "Unable to determine median normalisation");
                 psFree(stats);
                 psFree(sumMatrix);
@@ -1134,5 +1135,5 @@
             psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); // Statistics for norm
             if (!psVectorStats(stats, norms, NULL, NULL, 0)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to determine median normalisation");
+                psError(PM_ERR_DATA, false, "Unable to determine median normalisation");
                 psFree(stats);
                 psFree(sumMatrix);
@@ -1371,5 +1372,5 @@
                                                           false); // Kernel image
                 if (!image) {
-                    psError(PS_ERR_UNKNOWN, false, "Unable to generate image of kernel.");
+                    psError(psErrorCodeLast(), false, "Unable to generate image of kernel.");
                     return false;
                 }
@@ -1947,5 +1948,5 @@
             psVector *w = NULL;
             if (!psMatrixSVD (&U, &w, &V, kernelMatrix)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to perform SVD on sumMatrix\n");
+                psError(psErrorCodeLast(), false, "failed to perform SVD on sumMatrix\n");
                 return NULL;
             }
@@ -2087,5 +2088,5 @@
             psImage *luMatrix = psMatrixLUDecomposition(NULL, &permutation, sumMatrix);
             if (!luMatrix) {
-                psError(PS_ERR_UNKNOWN, true, "LU Decomposition of least-squares matrix failed.\n");
+                psError(PM_ERR_DATA, true, "LU Decomposition of least-squares matrix failed.\n");
                 psFree(solution);
                 psFree(sumVector);
@@ -2100,5 +2101,5 @@
             psFree(permutation);
             if (!solution) {
-                psError(PS_ERR_UNKNOWN, true, "Failed to solve the least-squares system.\n");
+                psError(PM_ERR_DATA, true, "Failed to solve the least-squares system.\n");
                 psFree(solution);
                 psFree(sumVector);
