Index: trunk/psModules/src/pmFlatField.c
===================================================================
--- trunk/psModules/src/pmFlatField.c	(revision 1849)
+++ trunk/psModules/src/pmFlatField.c	(revision 1852)
@@ -18,6 +18,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-09-22 19:58:57 $
+ *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-09-22 23:58:20 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -34,4 +34,6 @@
 #include "pmFlatField.h"
 #include "pmMaskBadPixels.h"
+#include "pmFlatFieldErrors.h"
+
 
 bool pmFlatField(psReadout *in, const psReadout *flat)
@@ -53,5 +55,6 @@
         return false;
     } else if(flat==NULL) {
-        psError(__func__, " : Line %d - Null not allowed for flat readout", __LINE__);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_NULL, true,
+                   PS_ERRORTEXT_pmFlatField_NULL_FLAT_READOUT);
         return false;
     }
@@ -60,8 +63,10 @@
     flatImage = flat->image;
     if (inImage == NULL) {
-        psError(__func__, " : Line %d - Null not allowed for input image", __LINE__);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_NULL, true,
+                   PS_ERRORTEXT_pmFlatField_NULL_INPUT_IMAGE);
         return false;
     } else if(flatImage == NULL) {
-        psError(__func__, " : Line %d - Null not allowed for flat image", __LINE__);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_NULL, true,
+                   PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE);
         return false;
     } else if(in->mask == NULL) {
@@ -72,10 +77,12 @@
     // Check input image and its mask are not larger than flat image
     if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
-        psError(__func__, " : Line %d - Input image size exceeds that of flat image: (%d, %d) vs (%d, %d)",
-                __LINE__, inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_SIZE, true,
+                   PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE,
+                   inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
         return false;
     } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) {
-        psError(__func__, " : Line %d - Input image mask size exceeds that of flat image: (%d, %d) vs (%d, %d)",
-                __LINE__, inMask->numRows, inMask->numCols, flatImage->numRows, flatImage->numCols);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_SIZE, true,
+                   PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE,
+                   inMask->numRows, inMask->numCols, flatImage->numRows, flatImage->numCols);
         return false;
     }
@@ -87,14 +94,17 @@
     // Check that offsets are within image limits
     if(totOffRow>=flatImage->numRows || totOffCol>=flatImage->numCols) {
-        psError(__func__, " : Line %d - Total offset >= flat image size: (%d, %d) vs (%d, %d)",
-                __LINE__, totOffRow, totOffCol, flatImage->numRows, flatImage->numCols);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_SIZE, true,
+                   PS_ERRORTEXT_pmFlatField_OFFSET_FLAT_IMAGE,
+                   totOffRow, totOffCol, flatImage->numRows, flatImage->numCols);
         return false;
     } else if(totOffRow>=inImage->numRows || totOffCol>=inImage->numCols) {
-        psError(__func__, " : Line %d - Total offset >= input image: (%d, %d) vs (%d, %d)",
-                __LINE__, totOffRow, totOffCol, inImage->numRows, inImage->numCols);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_SIZE, true,
+                   PS_ERRORTEXT_pmFlatField_OFFSET_INPUT_IMAGE,
+                   totOffRow, totOffCol, inImage->numRows, inImage->numCols);
         return false;
     } else if(totOffRow>=inMask->numRows || totOffCol>=inMask->numCols) {
-        psError(__func__, " : Line %d - Total offset >= input image mask: (%d, %d) vs (%d, %d)",
-                __LINE__, totOffRow, totOffCol, inMask->numRows, inMask->numCols);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_SIZE, true,
+                   PS_ERRORTEXT_pmFlatField_OFFSET_MASK_IMAGE,
+                   totOffRow, totOffCol, inMask->numRows, inMask->numCols);
         return false;
     }
@@ -105,17 +115,22 @@
     maskType = inMask->type.type;
     if(PS_IS_PSELEMTYPE_COMPLEX(inType)) {
-        psError(__func__, " : Line %d - Complex types not allowed for input image. Type: %d", __LINE__,
-                inType);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_pmFlatField_TYPE_INPUT_IMAGE,
+                   inType);
         return false;
     } else if(PS_IS_PSELEMTYPE_COMPLEX(flatType)) {
-        psError(__func__, " : Line %d - Complex types not allowed for flat image. Type: %d", __LINE__,
-                flatType);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_pmFlatField_TYPE_FLAT_IMAGE,
+                   flatType);
         return false;
     } else if(maskType != PS_TYPE_MASK) {
-        psError(__func__, " : Line %d - Mask must be PS_TYPE_MASK type. Type: %d", __LINE__, maskType);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_pmFlatField_TYPE_MASK_IMAGE,
+                   maskType);
         return false;
     } else if(inType != flatType) {
-        psError(__func__, " : Line %d - Input and flat image types differ: (%d vs %d)", __LINE__, inType,
-                flatType);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_pmFlatField_TYPE_MISMATCH,
+                   inType, flatType);
         return false;
     }
@@ -155,5 +170,7 @@
         PM_FLAT_DIVISION(F64);
     default:
-        psError(__func__, "Unsupported image datatype. Type: %d", inType);
+        psErrorMsg(PS_ERRORNAME_DOMAIN "pmFlatField", PS_ERR_BAD_PARAMETER_TYPE, true,
+                   PS_ERRORTEXT_pmFlatField_TYPE_UNSUPPORTED,
+                   inType);
     }
 
