home *** CD-ROM | disk | FTP | other *** search
/ 3D GFX / 3D GFX.iso / amiutils / i_l / irit5 / triv_lib / triv_err.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-31  |  3.4 KB  |  67 lines

  1. /******************************************************************************
  2. * Triv_err.c - handler for all triv library fatal errors.              *
  3. *******************************************************************************
  4. * Written by Gershon Elber, May. 91.                          *
  5. ******************************************************************************/
  6.  
  7. #include "triv_loc.h"
  8.  
  9. typedef struct TrivErrorStruct {
  10.     TrivFatalErrorType ErrorNum;
  11.     char *ErrorDesc;
  12. } TrivErrorStruct;
  13.  
  14. static TrivErrorStruct ErrMsgs[] =
  15. {
  16.     { TRIV_ERR_DIR_NOT_VALID,    "Dir is not valid" },
  17.     { TRIV_ERR_UNDEF_CRV,    "Undefined curve type" },
  18.     { TRIV_ERR_UNDEF_SRF,    "Undefined surface type" },
  19.     { TRIV_ERR_UNDEF_CRV,    "Undefined curve type" },
  20.     { TRIV_ERR_UNDEF_TRIVAR,    "Undefined trivariate type" },
  21.     { TRIV_ERR_UNDEF_GEOM,    "Undefined geometry type" },
  22.     { TRIV_ERR_RATIONAL_NO_SUPPORT, "Rational function is not supported" },
  23.     { TRIV_ERR_WRONG_ORDER,    "Provided order is wrong" },
  24.     { TRIV_ERR_KNOT_NOT_ORDERED,"Provided knots are not in ascending order" },
  25.     { TRIV_ERR_NUM_KNOT_MISMATCH,"Number of knots does not match" },
  26.     { TRIV_ERR_INDEX_NOT_IN_MESH,"Index is out of mesh range" },
  27.     { TRIV_ERR_POWER_NO_SUPPORT,"Power basis type is not supported" },
  28.     { TRIV_ERR_WRONG_DOMAIN,    "Given parameter is not in domain" },
  29.     { TRIV_ERR_DIR_NOT_CONST_UVW, "Given direction is not U, V or W" },
  30.     { TRIV_ERR_SCALAR_PT_EXPECTED,"A scalar field trivariate is expected." },
  31.     { TRIV_ERR_NO_CLOSED_POLYGON,"Failed to form a closed polygon." },
  32.     { TRIV_ERR_TWO_INTERSECTIONS,"Should have found two intersections only." },
  33.     { TRIV_ERR_NO_MATCH_PAIR,    "Cannot find matching pairs." },
  34.     { TRIV_ERR_2_OR_4_INTERS,    "Only two or four intersections in a face." },
  35.     { TRIV_ERR_FAIL_FIND_PT,     "Failed to find next point." },
  36.  
  37.     { TRIV_ERR_UNDEFINE_ERR,    NULL }
  38. };
  39.  
  40. /*****************************************************************************
  41. * DESCRIPTION:                                                               M
  42. * Returns a string describing a the given error. Errors can be raised by     M
  43. * any member of this triv library as well as other users. Raised error will  M
  44. * cause an invokation of TrivFatalError function which decides how to handle M
  45. * this error. TrivFatalError can for example, invoke this routine with the   M
  46. * error type, print the appropriate message and quit the program.            M
  47. *                                                                            *
  48. * PARAMETERS:                                                                M
  49. *   ErrorNum:   Type of the error that was raised.                           M
  50. *                                                                            *
  51. * RETURN VALUE:                                                              M
  52. *   char *:     A string describing the error type.                          M
  53. *                                                                            *
  54. * KEYWORDS:                                                                  M
  55. *   TrivDescribeError, error handling                                        M
  56. *****************************************************************************/
  57. char *TrivDescribeError(TrivFatalErrorType ErrorNum)
  58. {
  59.     int i = 0;
  60.  
  61.     for ( ; ErrMsgs[i].ErrorDesc != NULL; i++)
  62.     if (ErrorNum == ErrMsgs[i].ErrorNum)
  63.         return ErrMsgs[i].ErrorDesc;
  64.  
  65.     return "Undefined error";
  66. }
  67.