source: git/Singular/mpsr_Error.cc @ 6ce030f

jengelh-datetimespielwiese
Last change on this file since 6ce030f was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • 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 "config.h"
15#include <kernel/mod2.h>
16
17#ifdef HAVE_MPSR
18
19#include <kernel/febase.h>
20#include <Singular/mpsr.h>
21
22const char *mpsr_errlist[] =
23{
24  "mpsr_Failure",
25  "mpsr_Success",
26  "Low-level MP error",
27  "MP (resp. MPT) syntax error",
28  "Object of unknown type to put",
29  "Object of wrong type to put",
30  "Unknown Singular token to put",
31  "Unknown dictionary item to get",
32  "Unknown operator to get",
33  "Unknown MP Node Type",
34  "Prototype found where it can not be handled",
35  "Wrong Number of Args",
36  "Wrong Argument Type",
37  "Wrong MP Node Type",
38  "Required Annot Skip",
39  "Wrong Union Discriminator",
40  "Unknown Coefficient Domain Specifications",
41};
42
43
44static mpsr_Status_t mpsr_errno = mpsr_Success;
45static MP_Errors mpsr_MP_errno = MP_Failure;
46
47mpsr_Status_t mpsr_SetError(mpsr_Status_t error)
48{
49  mpsr_errno = error;
50  return error;
51}
52
53mpsr_Status_t mpsr_SetError(MP_Link_pt link)
54{
55  mpsr_SetError(mpsr_MP_Failure);
56  mpsr_MP_errno = (enum MP_Errors) link->MP_errno;
57  return mpsr_MP_Failure;
58}
59
60void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link)
61{
62  if (error != mpsr_Success)
63  {
64    if (error == mpsr_MP_Failure)
65      Werror("%s : %s", mpsr_errlist[error],
66             (link != NULL ? MP_ErrorStr(link) :
67              (mpsr_MP_errno < MP_MaxError ? MP_errlist[mpsr_MP_errno] :
68               "Unknown MP error")));
69    else if (error == mpsr_MPT_Failure)
70      Werror("%s : %s", mpsr_errlist[error],
71             ((MPT_errno == MPT_MP_Failure && link != NULL) ?
72              MP_ErrorStr(link) : MPT_ErrorStr(MPT_errno)));
73    else Werror("MP<->Singular interface error : %s",
74                (mpsr_errno < mpsr_MaxError ? mpsr_errlist[mpsr_errno] :
75                 "Unknown mpsr error"));
76  }
77
78}
79void mpsr_PrintError(MP_Link_pt link)
80{
81  mpsr_PrintError(mpsr_errno, link);
82}
83
84void mpsr_PrintError(mpsr_Status_t error)
85{
86  mpsr_PrintError(error, NULL);
87}
88
89
90void mpsr_PrintError()
91{
92  mpsr_PrintError(mpsr_errno, NULL);
93}
94
95mpsr_Status_t mpsr_GetError()
96{
97  return mpsr_errno;
98}
99
100void mpsr_ClearError()
101{
102  mpsr_errno = mpsr_Success;
103}
104#endif
Note: See TracBrowser for help on using the repository browser.