source: git/Singular/mpsr_Error.cc @ 286bd57

spielwiese
Last change on this file since 286bd57 was 286bd57, checked in by Olaf Bachmann <obachman@…>, 27 years ago
Fri Mar 28 14:12:05 1997 Olaf Bachmann <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)> * Added routines dump(link) and getdump(link) for ascii and MP links * ipconv.cc (dConvertTypes): added int->module conversion so that 'module m = 0' works * iparith.cc (jjVAR1): added LINK_CMD to list of typeof(...) git-svn-id: file:///usr/local/Singular/svn/trunk@124 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4
5/***************************************************************
6 *
7 * File:       mpsr_Error.cc
8 * Purpose:    Error handling of mpsr routines
9 * Author:     Olaf Bachmann (2/97)
10 *
11 * Change History (most recent first):
12 *
13 ***************************************************************/
14#include "mod2.h"
15
16#ifdef HAVE_MPSR
17
18#include "febase.h"
19#include"mpsr.h"
20
21extern "C"
22{
23#include"MPT.h"
24}
25
26char *mpsr_errlist[] =
27{
28  "mpsr_Failure",
29  "mpsr_Success",
30  "Low-level MP error",
31  "MP (resp. MPT) syntax error",
32  "Object of unknown type to put",
33  "Object of wrong type to put",
34  "Unknown Singular token to put",
35  "Unknown dictionary item to get",
36  "Unknown operator to get",
37  "Unknown MP Node Type",
38  "Prototype found where it can not be handled",
39  "Wrong Number of Args",
40  "Wrong Argument Type",
41  "Wrong MP Node Type",
42  "Required Annot Skip",
43  "Wrong Union Discriminator",
44  "Unknown Coefficient Domain Specifications",
45};
46
47
48static mpsr_Status_t mpsr_errno = mpsr_Success;
49static mpsr_MP_errno = MP_Failure;
50
51mpsr_Status_t mpsr_SetError(mpsr_Status_t error)
52{
53  mpsr_errno = error;
54  return error;
55}
56
57mpsr_Status_t mpsr_SetError(MP_Link_pt link)
58{
59  mpsr_SetError(mpsr_MP_Failure);
60  mpsr_MP_errno = link->errno;
61  return mpsr_MP_Failure;
62}
63
64void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link)
65{
66  if (error != mpsr_Success)
67  {
68    if (error == mpsr_MP_Failure)
69      Werror("%s : %s", mpsr_errlist[error],
70             (link != NULL ? MP_ErrorStr(link) :
71              (mpsr_MP_errno < MP_MaxError ? MP_errlist[mpsr_MP_errno] :
72               "Unknown MP error")));
73    else if (error == mpsr_MPT_Failure)
74      Werror("%s : %s", mpsr_errlist[error],
75             ((MPT_errno == MPT_MP_Failure && link != NULL) ?
76              MP_ErrorStr(link) : MPT_ErrorStr(MPT_errno)));
77    else Werror("MP<->Singular interface error : %s",
78                (mpsr_errno < mpsr_MaxError ? mpsr_errlist[mpsr_errno] :
79                 "Unknown mpsr error"));
80  }
81 
82}
83void mpsr_PrintError(MP_Link_pt link)
84{
85  mpsr_PrintError(mpsr_errno, link);
86}
87
88void mpsr_PrintError(mpsr_Status_t error)
89{
90  mpsr_PrintError(error, NULL);
91}
92
93
94void mpsr_PrintError()
95{
96  mpsr_PrintError(mpsr_errno, NULL);
97}
98
99mpsr_Status_t mpsr_GetError()
100{
101  return mpsr_errno;
102}
103
104void mpsr_ClearError()
105{
106  mpsr_errno = mpsr_Success;
107}
108#endif
Note: See TracBrowser for help on using the repository browser.