Index: trunk/pswarp/src/pswarpDefine.c
===================================================================
--- trunk/pswarp/src/pswarpDefine.c	(revision 26896)
+++ trunk/pswarp/src/pswarpDefine.c	(revision 27096)
@@ -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,5 +77,5 @@
         psFree(readout);                // Drop reference
 
-	bool status = false;
+        bool status = false;
         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XBIN");
         psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YBIN");
@@ -106,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;
@@ -118,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;
