source: git/MP/MPT/MPT_Error.cc @ 4d9c27

spielwiese
Last change on this file since 4d9c27 was 4d9c27, checked in by Olaf Bachmann <obachman@…>, 25 years ago
* added .cc files and new GP stuff git-svn-id: file:///usr/local/Singular/svn/trunk@2649 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/******************************************************************
2 *
3 * File:    MPT_Error.c
4 * Purpose: Routines related to Error handling of MPT
5 * Author:  Olaf Bachman (obachman@mathematik.uni-kl.de)
6 * Created: 12/96
7 *
8 * Change History (most recent first):
9 *     
10 ******************************************************************/
11
12#include "MPT.h"
13
14char *MPT_errlist[] =
15{
16  "MPT: MPT_Failure",
17  "MPT: MPT_Success",
18  "MPT: MPT_MP_Failure",
19  "MPT: Unknown Type",
20  "MPT: Can't allocate memory",
21  "MPT: MPT tree has wrong syntax/structure",
22  "MPT: MP node of unknown type",
23  "MPT: ProtoD:Pointer without Arg",
24  "MPT: Union Discriminator too large (out of permissible range)",
25  "MPT: An internal assumption has been violated",
26  "MPT: External application did not read data from link",
27  "MPT: Wrong ApInt format requested"
28};
29
30
31MPT_Status_t MPT_errno = MPT_Success;
32
33MPT_Status_t MPT_CheckError()
34{
35  MPT_Status_t status = MPT_errno;
36  MPT_ClearError();
37  return status;
38}
39
40char*  MPT_ErrorStr(MPT_Status_t error)
41{
42  if (error < MPT_MaxError && error > 0)
43    return MPT_errlist[error];
44  else
45    return "Unknown MPT error number";
46}
47
48char* MPT_LinkErrorStr(MP_Link_pt link, MPT_Status_t error)
49{
50  if (error == MPT_MP_Failure &&
51      link != NULL && link->errno >= 0 && link->errno != MP_Success)
52    return MP_ErrorStr(link);
53 
54  if (error >= 0 && error < MPT_MaxError)
55    return MPT_errlist[error];
56 
57  return "MPT: Unknown Error";
58}
59
60#ifdef MPT_DEBUG
61MPT_Status_t MPT_SetError(MPT_Status_t mpt_error)
62{
63  return MPT_errno = mpt_error;
64}
65
66MPT_Status_t MPT_ClearError()
67{
68  return MPT_errno = MPT_Success;
69}
70
71/* when debugging is turned on, this function gets called, whenever
72   MPT_Assume is used */
73void MPT_Assume(MP_Boolean_t ass)
74{
75  if (!ass)
76  {
77    MPT_SetError(MPT_ViolatedAssumption);
78  }
79}
80#endif
81
82
Note: See TracBrowser for help on using the repository browser.