home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / i / iritsm3s.zip / cagd_lib / cagd_err.c < prev    next >
C/C++ Source or Header  |  1991-09-26  |  2KB  |  52 lines

  1. /******************************************************************************
  2. * Cagd_err.c - handler for all cagd library fatal errors.              *
  3. *******************************************************************************
  4. * Written by Gershon Elber, May. 91.                          *
  5. ******************************************************************************/
  6.  
  7. #include "cagd_loc.h"
  8.  
  9. typedef struct CagdErrorStruct {
  10.     CagdFatalErrorType ErrorNum;
  11.     char *ErrorDesc;
  12. } CagdErrorStruct;
  13.  
  14. static CagdErrorStruct ErrMsgs[] =
  15. {
  16.     { CAGD_ERR_180_ARC,            "Attempt to construct a 180 degrees arc" },
  17.     { CAGD_ERR_PT_OR_LEN_MISMATCH,    "Curve PtType or Length mismatch surface" },
  18.     { CAGD_ERR_CRVS_INCOMPATIBLE,    "Curves for rules surface are incompatible" },
  19.     { CAGD_ERR_RAT_LIN_NO_SUPPORT,    "Derivative of rational/linear is not supported" },
  20.     { CAGD_ERR_DIR_NOT_CONST_UV,    "Dir is not one of CONST_U/V_DIR" },
  21.     { CAGD_ERR_T_NOT_IN_CRV,        "Given t is not in curve parametric domain" },
  22.     { CAGD_ERR_U_NOT_IN_SRF,        "Given u is not in u surface parametric domain" },
  23.     { CAGD_ERR_V_NOT_IN_SRF,        "Given v is not in v surface parametric domain" },
  24.     { CAGD_ERR_INDEX_NOT_IN_MESH,    "Index is out of mesh range" },
  25.     { CAGD_ERR_NUM_KNOT_MISMATCH,    "Number of knots does not match" },
  26.     { CAGD_ERR_PARSER_STACK_OV,        "Parser Internal stack overflow.." },
  27.     { CAGD_ERR_KNOT_NOT_ORDERED,    "Provided knots are not in ascending order" },
  28.     { CAGD_ERR_UNDEF_CRV,        "Undefined curve type" },
  29.     { CAGD_ERR_UNDEF_SRF,        "Undefined surface type" },
  30.     { CAGD_ERR_UNSUPPORT_PT,        "Unsupported point type" },
  31.     { CAGD_ERR_POWER_NO_SUPPORT,    "Power basis type is not supported" },
  32.     { CAGD_ERR_NOT_IMPLEMENTED,        "Not implemented" },
  33.     { CAGD_ERR_ALLOC_ERR,        "Memory allocation error" },
  34.     { CAGD_ERR_NOT_ENOUGH_MEM,        "Not enough memory, exit" },
  35.     { CAGD_ERR_WRONG_ORDER,        "Provided order is wrong" },
  36.     { CAGD_ERR_UNDEFINE_ERR,        NULL }
  37. };
  38.  
  39. /******************************************************************************
  40. * Returns a string describing a the given error.                  *
  41. ******************************************************************************/
  42. char *CagdDescribeError(CagdFatalErrorType ErrorNum)
  43. {
  44.     int i = 0;
  45.  
  46.     for ( ; ErrMsgs[i].ErrorDesc != NULL; i++)
  47.     if (ErrorNum == ErrMsgs[i].ErrorNum)
  48.         return ErrMsgs[i].ErrorDesc;
  49.  
  50.     return "Undefined error";
  51. }
  52.