Index: trunk/psModules/src/objects/pmPSF.c
===================================================================
--- trunk/psModules/src/objects/pmPSF.c	(revision 13064)
+++ trunk/psModules/src/objects/pmPSF.c	(revision 13426)
@@ -6,6 +6,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-04-27 22:14:08 $
+ *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-05-18 14:08:34 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -36,4 +36,5 @@
 #include "pmFPAMaskWeight.h"
 #include "psVectorBracket.h"
+#include "pmErrorCodes.h"
 
 /*****************************************************************************/
@@ -178,5 +179,11 @@
 
     // set model parameters for this source based on PSF information
-    modelFromPSFFunc (modelPSF, modelEXT, psf);
+    if (!modelFromPSFFunc (modelPSF, modelEXT, psf)) {
+	psError(PM_ERR_PSF, true, "Failed to set model params from PSF");
+	psFree(modelPSF);
+	return NULL;
+    }
+    // XXX note that model->residuals is just a reference
+    modelPSF->residuals = psf->residuals;
 
     return (modelPSF);
@@ -248,5 +255,10 @@
     pol.e2 = fittedPar[PM_PAR_E2];
 
-    psEllipseAxes axes = psEllipsePolToAxes (pol, minMinorAxis);
+    psEllipseAxes axes;
+    if (psEllipsePolToAxes (pol, minMinorAxis, &axes) != PS_ERR_NONE) {
+	psError(PM_ERR_PSF, false, "Failed to convert e[012] (%g,%g,%g) to axes",
+		pol.e0, pol.e1, pol.e2);
+	return false;
+    }
     psEllipseShape shape = psEllipseAxesToShape (axes);
 
@@ -519,4 +531,5 @@
     // no need to interpolate since we have forced the object center
     // to 0.5, 0.5 above
+    bool completeGrowthCurve = true;		// do we have a complete curve of growth?
     for (int i = 0; i < psf->growth->radius->n; i++) {
 
@@ -525,5 +538,9 @@
         // mask the given aperture and measure the apMag
         psImageKeepCircle (mask, xc, yc, radius, "OR", PM_MASK_MARK);
-        pmSourcePhotometryAper (&apMag, model, image, mask);
+        if (!pmSourcePhotometryAper (&apMag, model, image, mask)) {
+	    psError(PM_ERR_PHOTOM, false, "Measuring apMag for radius == %g", radius);
+	    completeGrowthCurve = false;
+	    break;
+	}
 
 	// XXX since we re-mask on each pass, this could be dropped.
@@ -538,6 +555,11 @@
     }
 
-    psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
-    psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
+    if (completeGrowthCurve) {
+	psf->growth->apRef = psVectorInterpolate (psf->growth->radius, psf->growth->apMag, psf->growth->refRadius);
+	psf->growth->apLoss = psf->growth->fitMag - psf->growth->apRef;
+    } else {
+	psf->growth->apRef = NAN;
+	psf->growth->apLoss = 0;
+    }
 
     psLogMsg ("psphot.growth", 4, "GrowthCurve : apLoss : %f\n", psf->growth->apLoss);
@@ -549,4 +571,4 @@
     psFree (modelRef);
 
-    return true;
-}
+    return completeGrowthCurve ? true : false;
+}
