source: git/Singular/mpsr_Error.cc @ 667ba1

spielwiese
Last change on this file since 667ba1 was 762407, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
config.h is for sources files only FIX: config.h should only be used by source (not from inside kernel/mod2.h!) NOTE: each source file should better include mod2.h right after config.h, while headers should better not include mod2.h.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id$ */
5
6/***************************************************************
7 *
8 * File:       mpsr_Error.cc
9 * Purpose:    Error handling of mpsr routines
10 * Author:     Olaf Bachmann (2/97)
11 *
12 * Change History (most recent first):
13 *
14 ***************************************************************/
15#include "config.h"
16#include <kernel/mod2.h>
17
18#ifdef HAVE_MPSR
19
20#include <kernel/febase.h>
21#include <Singular/mpsr.h>
22
23const char *mpsr_errlist[] =
24{
25  "mpsr_Failure",
26  "mpsr_Success",
27  "Low-level MP error",
28  "MP (resp. MPT) syntax error",
29  "Object of unknown type to put",
30  "Object of wrong type to put",
31  "Unknown Singular token to put",
32  "Unknown dictionary item to get",
33  "Unknown operator to get",
34  "Unknown MP Node Type",
35  "Prototype found where it can not be handled",
36  "Wrong Number of Args",
37  "Wrong Argument Type",
38  "Wrong MP Node Type",
39  "Required Annot Skip",
40  "Wrong Union Discriminator",
41  "Unknown Coefficient Domain Specifications",
42};
43
44
45static mpsr_Status_t mpsr_errno = mpsr_Success;
46static MP_Errors mpsr_MP_errno = MP_Failure;
47
48mpsr_Status_t mpsr_SetError(mpsr_Status_t error)
49{
50  mpsr_errno = error;
51  return error;
52}
53
54mpsr_Status_t mpsr_SetError(MP_Link_pt link)
55{
56  mpsr_SetError(mpsr_MP_Failure);
57  mpsr_MP_errno = (enum MP_Errors) link->MP_errno;
58  return mpsr_MP_Failure;
59}
60
61void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link)
62{
63  if (error != mpsr_Success)
64  {
65    if (error == mpsr_MP_Failure)
66      Werror("%s : %s", mpsr_errlist[error],
67             (link != NULL ? MP_ErrorStr(link) :
68              (mpsr_MP_errno < MP_MaxError ? MP_errlist[mpsr_MP_errno] :
69               "Unknown MP error")));
70    else if (error == mpsr_MPT_Failure)
71      Werror("%s : %s", mpsr_errlist[error],
72             ((MPT_errno == MPT_MP_Failure && link != NULL) ?
73              MP_ErrorStr(link) : MPT_ErrorStr(MPT_errno)));
74    else Werror("MP<->Singular interface error : %s",
75                (mpsr_errno < mpsr_MaxError ? mpsr_errlist[mpsr_errno] :
76                 "Unknown mpsr error"));
77  }
78
79}
80void mpsr_PrintError(MP_Link_pt link)
81{
82  mpsr_PrintError(mpsr_errno, link);
83}
84
85void mpsr_PrintError(mpsr_Status_t error)
86{
87  mpsr_PrintError(error, NULL);
88}
89
90
91void mpsr_PrintError()
92{
93  mpsr_PrintError(mpsr_errno, NULL);
94}
95
96mpsr_Status_t mpsr_GetError()
97{
98  return mpsr_errno;
99}
100
101void mpsr_ClearError()
102{
103  mpsr_errno = mpsr_Success;
104}
105#endif
Note: See TracBrowser for help on using the repository browser.