Index: branches/tap_branches/pswarp/src/pswarpDefine.c
===================================================================
--- branches/tap_branches/pswarp/src/pswarpDefine.c	(revision 25900)
+++ branches/tap_branches/pswarp/src/pswarpDefine.c	(revision 27838)
@@ -49,5 +49,5 @@
     {
         if (!pmFPAReadHeaderSet(skycell->fpa, skycell->fits, config)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read headers for skycell.");
+            psError(psErrorCodeLast(), false, "Unable to read headers for skycell.");
             psFree(view);
             return false;
@@ -59,5 +59,5 @@
         pmHDU *hdu = pmHDUFromCell(source); ///< HDU for source
         if (!hdu || !hdu->header) {
-            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find header for sky cell.");
+            psError(PM_ERR_PROG, false, "Unable to find header for sky cell.");
             psFree(view);
             return false;
@@ -65,6 +65,6 @@
         int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); ///< Number of columns
         int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); ///< Number of rows
-	if ((numCols == 0) || (numRows == 0)) {
-            psError(PS_ERR_UNKNOWN, false, "skycell has invalid dimensions %d x %d", numCols, numRows);
+        if ((numCols == 0) || (numRows == 0)) {
+            psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows);
             psFree(view);
             return false;
@@ -77,12 +77,13 @@
         psFree(readout);                // Drop reference
 
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XBIN");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YBIN");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XSIZE");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YSIZE");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XPARITY");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YPARITY");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.X0");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.Y0");
+        bool status = false;
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XBIN");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YBIN");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XSIZE");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YSIZE");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XPARITY");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YPARITY");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.X0");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.Y0");
     }
 
@@ -105,10 +106,10 @@
     if (bilevelAstrometry) {
         if (!pmAstromReadBilevelMosaic(output->fpa, phu->header)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for skycell.");
+            psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for skycell.");
             psFree(view);
             return false;
         }
         if (!pmAstromReadBilevelChip(outputChip, hdu->header)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for skycell.");
+            psError(psErrorCodeLast(), false, "Unable to read bilevel chip astrometry for skycell.");
             psFree(view);
             return false;
@@ -117,5 +118,5 @@
         // we use a default FPA pixel scale of 1.0
         if (!pmAstromReadWCS(output->fpa, outputChip, hdu->header, 1.0)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for skycell.");
+            psError(psErrorCodeLast(), false, "Unable to read WCS astrometry for skycell.");
             psFree(view);
             return false;
