Index: trunk/ppSub/src/ppSubCamera.c
===================================================================
--- trunk/ppSub/src/ppSubCamera.c	(revision 26899)
+++ trunk/ppSub/src/ppSubCamera.c	(revision 26982)
@@ -45,5 +45,5 @@
 
     if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
+        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
         return false;
     }
@@ -52,5 +52,5 @@
         file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
         if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
+            psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
             return NULL;
         }
@@ -64,5 +64,5 @@
 
     if (file->type != fileType) {
-        psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
+        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
         return NULL;
     }
@@ -84,9 +84,9 @@
         pmFPAfileDefineOutput(config, template->fpa, filerule);
     if (!file) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), filerule);
+        psError(psErrorCodeLast(), false, _("Unable to generate output file from %s"), filerule);
         return NULL;
     }
     if (file->type != fileType) {
-        psError(PS_ERR_IO, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
+        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
         return NULL;
     }
@@ -109,5 +109,5 @@
     pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
     if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
+        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
         return NULL;
     }
@@ -121,5 +121,5 @@
         file = pmFPAfileDefineOutput(config, bind ? bind->fpa : NULL, filerule);
         if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "Failed to load file definition for %s", filerule);
+            psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
             return false;
         }
@@ -135,5 +135,5 @@
 
     if (file->type != fileType) {
-        psError(PS_ERR_UNKNOWN, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
+        psError(PPSUB_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
         return NULL;
     }
@@ -154,5 +154,5 @@
     pmFPAfile *input = defineInputFile(&success, config, NULL, "PPSUB.INPUT", "INPUT", PM_FPA_FILE_IMAGE);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT");
         return false;
     }
@@ -160,5 +160,5 @@
     defineInputFile(&success, config, input, "PPSUB.INPUT.MASK", "INPUT.MASK", PM_FPA_FILE_MASK);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT.MASK");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.MASK");
         return false;
     }
@@ -166,5 +166,5 @@
     pmFPAfile *inVar = defineInputFile(&success, config, input, "PPSUB.INPUT.VARIANCE", "INPUT.VARIANCE", PM_FPA_FILE_VARIANCE);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT.VARIANCE");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.VARIANCE");
         return false;
     }
@@ -172,5 +172,5 @@
     defineInputFile(&success, config, NULL, "PPSUB.INPUT.SOURCES", "INPUT.SOURCES", PM_FPA_FILE_CMF);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.INPUT.SOURCES");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.INPUT.SOURCES");
         return false;
     }
@@ -179,5 +179,5 @@
     pmFPAfile *ref = defineInputFile(&success, config, NULL, "PPSUB.REF", "REF", PM_FPA_FILE_IMAGE);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF");
         return false;
     }
@@ -185,5 +185,5 @@
     defineInputFile(&success, config, ref, "PPSUB.REF.MASK", "REF.MASK", PM_FPA_FILE_MASK);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF.MASK");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.MASK");
         return false;
     }
@@ -191,5 +191,5 @@
     pmFPAfile *refVar = defineInputFile(&success, config, ref, "PPSUB.REF.VARIANCE", "REF.VARIANCE", PM_FPA_FILE_VARIANCE);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF.VARIANCE");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.VARIANCE");
         return false;
     }
@@ -197,5 +197,5 @@
     defineInputFile(&success, config, NULL, "PPSUB.REF.SOURCES", "REF.SOURCES", PM_FPA_FILE_CMF);
     if (!success) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPSUB.REF.SOURCES");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PPSUB.REF.SOURCES");
         return false;
     }
@@ -204,5 +204,5 @@
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     if (!recipe) {
-        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
+        psError(PPSUB_ERR_CONFIG, false, "Unable to find recipe %s", PPSUB_RECIPE);
         return false;
     }
@@ -227,5 +227,5 @@
                                              PM_FPA_FILE_MASK);
     if (!inConvImage || !inConvMask) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+        psError(psErrorCodeLast(), false, "Unable to define output files");
         return false;
     }
@@ -238,5 +238,5 @@
                                                 PM_FPA_FILE_VARIANCE);
         if (!inConvVar) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+            psError(psErrorCodeLast(), false, "Unable to define output files");
             return false;
         }
@@ -251,5 +251,5 @@
                                               PM_FPA_FILE_MASK);
     if (!refConvImage || !refConvMask) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+        psError(psErrorCodeLast(), false, "Unable to define output files");
         return false;
     }
@@ -262,5 +262,5 @@
                                                  PM_FPA_FILE_VARIANCE);
         if (!refConvVar) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+            psError(psErrorCodeLast(), false, "Unable to define output files");
             return false;
         }
@@ -274,5 +274,5 @@
     pmFPAfile *outMask = defineOutputFile(config, output, false, "PPSUB.OUTPUT.MASK", PM_FPA_FILE_MASK);
     if (!output || !outMask) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+        psError(psErrorCodeLast(), false, "Unable to define output files");
         return false;
     }
@@ -283,5 +283,5 @@
                                              PM_FPA_FILE_VARIANCE);
         if (!outVar) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+            psError(psErrorCodeLast(), false, "Unable to define output files");
             return false;
         }
@@ -296,5 +296,5 @@
                                               PM_FPA_FILE_MASK);
         if (!inverse || !invMask) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+            psError(psErrorCodeLast(), false, "Unable to define output files");
             return false;
         }
@@ -305,5 +305,5 @@
                                                  PM_FPA_FILE_VARIANCE);
             if (!invVar) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to define output files");
+                psError(psErrorCodeLast(), false, "Unable to define output files");
                 return false;
             }
@@ -316,9 +316,9 @@
     pmFPAfile *jpeg1 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG1");
     if (!jpeg1) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1"));
+        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG1"));
         return false;
     }
     if (jpeg1->type != PM_FPA_FILE_JPEG) {
-        psError(PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG");
+        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG1 is not of type JPEG");
         return false;
     }
@@ -326,9 +326,9 @@
     pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG2");
     if (!jpeg2) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2"));
+        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.JPEG2"));
         return false;
     }
     if (jpeg2->type != PM_FPA_FILE_JPEG) {
-        psError(PS_ERR_IO, true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG");
+        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.JPEG2 is not of type JPEG");
         return false;
     }
@@ -338,9 +338,9 @@
     pmFPAfile *jpeg3 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.RESID.JPEG");
     if (!jpeg3) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.RESID.JPEG"));
+        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSUB.OUTPUT.RESID.JPEG"));
         return false;
     }
     if (jpeg3->type != PM_FPA_FILE_JPEG) {
-        psError(PS_ERR_IO, true, "PPSUB.OUTPUT.RESID.JPEG is not of type JPEG");
+        psError(psErrorCodeLast(), true, "PPSUB.OUTPUT.RESID.JPEG is not of type JPEG");
         return false;
     }
@@ -360,9 +360,9 @@
         pmFPAfile *psphot = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.INPUT");
         if (!psphot) {
-            psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.INPUT");
+            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.INPUT");
             return false;
         }
         if (psphot->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PSPHOT.INPUT is not of type IMAGE");
+            psError(psErrorCodeLast(), true, "PSPHOT.INPUT is not of type IMAGE");
             return false;
         }
@@ -374,9 +374,9 @@
         pmFPAfile *psf = pmFPAfileDefineFromFPA(config, output->fpa, 1, 1, "PSPHOT.PSF.LOAD");
         if (!psf) {
-            psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");
+            psError(psErrorCodeLast(), false, "Failed to build FPA from PSPHOT.PSF.LOAD");
             return false;
         }
         if (psf->type != PM_FPA_FILE_PSF) {
-            psError(PS_ERR_IO, true, "PSPHOT.PSF.LOAD is not of type PSF");
+            psError(psErrorCodeLast(), true, "PSPHOT.PSF.LOAD is not of type PSF");
             return false;
         }
@@ -384,5 +384,5 @@
 
         if (!psphotDefineFiles(config, psphot)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to set up psphot files.");
+            psError(psErrorCodeLast(), false, "Unable to set up psphot files.");
             return false;
         }
@@ -395,5 +395,5 @@
                                                  PM_FPA_FILE_CMF);
         if (!outSources) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to set up output source file.");
+            psError(psErrorCodeLast(), false, "Unable to set up output source file.");
             return false;
         }
@@ -404,5 +404,5 @@
                                                      PM_FPA_FILE_CMF);
             if (!invSources) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to set up inverse source file.");
+                psError(psErrorCodeLast(), false, "Unable to set up inverse source file.");
                 return false;
             }
