Index: trunk/pswarp/src/pswarpLoop.c
===================================================================
--- trunk/pswarp/src/pswarpLoop.c	(revision 27063)
+++ trunk/pswarp/src/pswarpLoop.c	(revision 27096)
@@ -84,10 +84,10 @@
     psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSWARP_RECIPE);
     if (!recipe) {
-        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE);
+        psError(PSWARP_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE);
         return false;
     }
 
     if (!pswarpSetMaskBits(config)) {
-        psError(PS_ERR_IO, false, "failed to set mask bits");
+        psError(psErrorCodeLast(), false, "failed to set mask bits");
         return NULL;
     }
@@ -111,5 +111,5 @@
 
     if (astrom->camera != input->camera) {
-        psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match.");
+        psError(PSWARP_ERR_DATA, true, "Input camera and astrometry camera do not match.");
         return false;
     }
@@ -211,5 +211,5 @@
     if (bilevelAstrometry) {
         if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
+            psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for input FPA.");
             psFree(view);
             psFree(stats);
@@ -237,5 +237,5 @@
         if (bilevelAstrometry) {
             if (!pmAstromReadBilevelChip (chip, hdu->header)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input FPA.");
+                psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for input FPA.");
                 psFree(view);
                 psFree(stats);
@@ -245,5 +245,5 @@
             // we use a default FPA pixel scale of 1.0
             if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
+                psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for input FPA.");
                 psFree(view);
                 psFree(stats);
@@ -312,5 +312,5 @@
 
     if (!pswarpPixelsLit(output, stats, config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to calculate pixel regions.");
+        psError(psErrorCodeLast(), false, "Unable to calculate pixel regions.");
         psFree(cells);
         psFree(view);
@@ -349,5 +349,5 @@
 
     if (!pmConceptsAverageCells(outCell, cells, NULL, NULL, false)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to average cell concepts.");
+        psError(psErrorCodeLast(), false, "Unable to average cell concepts.");
         psFree(stats);
         psFree(cells);
@@ -361,5 +361,5 @@
 
     if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA concepts from input to output.");
+        psError(psErrorCodeLast(), false, "Unable to copy FPA concepts from input to output.");
         psFree(stats);
         psFree(view);
@@ -388,5 +388,5 @@
         pmHDU *skyHDU = pmHDUFromCell(cell); ///< HDU
         if (!skyHDU) {
-            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find skycell HDU.");
+            psError(PSWARP_ERR_DATA, false, "Unable to find skycell HDU.");
             psFree(view);
             return false;
@@ -398,5 +398,5 @@
 
     if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to generate WCS header.");
+        psError(psErrorCodeLast(), false, "Unable to generate WCS header.");
         psFree(stats);
         return false;
@@ -428,5 +428,5 @@
         psArray *sources = psphotLoadPSFSources (config, view);
         if (!sources) {
-            psError(PS_ERR_UNKNOWN, false, "No sources supplied to measure PSF");
+            psError(psErrorCodeLast(), false, "No sources supplied to measure PSF");
             return false;
         }
