Index: /trunk/psModules/src/pmFlatField.c
===================================================================
--- /trunk/psModules/src/pmFlatField.c	(revision 1851)
+++ /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);
     }
 
Index: /trunk/psModules/src/pmFlatField.dat
===================================================================
--- /trunk/psModules/src/pmFlatField.dat	(revision 1852)
+++ /trunk/psModules/src/pmFlatField.dat	(revision 1852)
@@ -0,0 +1,22 @@
+#
+#  This file is used to generate pmFlatFieldErrors.h content
+#
+#  Format is:
+#  ERRORNAME(one word)    ERRORTEXT
+#
+#  N.B. in code, the ERRORNAME appears as PS_ERRORTEXT_ERRORNAME
+####################################################################
+#
+pmFlatField_NULL_FLAT_READOUT          Null not allowed for flat readout.
+pmFlatField_NULL_INPUT_IMAGE           Null not allowed for input image.
+pmFlatField_NULL_FLAT_IMAGE            Null not allowed for flat image.
+pmFlatField_SIZE_INPUT_IMAGE           Input image size exceeds that of flat image: (%d, %d) vs (%d, %d)
+pmFlatField_SIZE_MASK_IMAGE            Input image mask size exceeds that of flat image: (%d, %d) vs (%d, %d)
+pmFlatField_OFFSET_FLAT_IMAGE          Total offset >= flat image size: (%d, %d) vs (%d, %d)
+pmFlatField_OFFSET_INPUT_IMAGE         Total offset >= input image: (%d, %d) vs (%d, %d)
+pmFlatField_OFFSET_MASK_IMAGE          Total offset >= input image mask: (%d, %d) vs (%d, %d)
+pmFlatField_TYPE_INPUT_IMAGE           Complex types not allowed for input image. Type: %d
+pmFlatField_TYPE_FLAT_IMAGE            Complex types not allowed for flat image. Type: %d
+pmFlatField_TYPE_MASK_IMAGE            Mask must be PS_TYPE_MASK type. Type: %d
+pmFlatField_TYPE_MISMATCH              Input and flat image types differ: (%d vs %d)
+pmFlatField_TYPE_UNSUPPORTED           Unsupported image datatype. Type: %d
Index: /trunk/psModules/src/psErrorCodes.dat
===================================================================
--- /trunk/psModules/src/psErrorCodes.dat	(revision 1852)
+++ /trunk/psModules/src/psErrorCodes.dat	(revision 1852)
@@ -0,0 +1,18 @@
+#
+#  This file is used to generate psErrorCode.h content
+#
+# Format:
+#    ERROR_CLASS_NAME    ERROR_CLASS_DESCRIPTION
+#
+# Note: the ERROR_CLASS_NAME will appear in the code with a "PS_ERR_" prefix
+#
+UNKNOWN                        unknown error
+IO                             I/O error
+LOCATION_INVALID               specified location is unknown
+MEMORY_CORRUPTION              memory corruption detected
+MEMORY_DEREF_USAGE             dereferenced memory still used
+BAD_PARAMETER_VALUE            parameter is out-of-range
+BAD_PARAMETER_TYPE             parameter is of unsupported type
+BAD_PARAMETER_NULL             parameter is null
+BAD_PARAMETER_SIZE             size of parameter's data is outside of acceptable range.
+UNEXPECTED_NULL                unexpected NULL found
