source: git/Singular/mpsr_Error.cc @ a113b0

fieker-DuValspielwiese
Last change on this file since a113b0 was 32df82, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: removed rcsid and Log: entries, added assignment module=poly corected type conversion int->module git-svn-id: file:///usr/local/Singular/svn/trunk@128 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/* $Id: mpsr_Error.cc,v 1.4 1997-04-02 15:07:36 Singular Exp $ */
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 "mod2.h"
16
17#ifdef HAVE_MPSR
18
19#include "febase.h"
20#include"mpsr.h"
21
22extern "C"
23{
24#include"MPT.h"
25}
26
27char *mpsr_errlist[] =
28{
29  "mpsr_Failure",
30  "mpsr_Success",
31  "Low-level MP error",
32  "MP (resp. MPT) syntax error",
33  "Object of unknown type to put",
34  "Object of wrong type to put",
35  "Unknown Singular token to put",
36  "Unknown dictionary item to get",
37  "Unknown operator to get",
38  "Unknown MP Node Type",
39  "Prototype found where it can not be handled",
40  "Wrong Number of Args",
41  "Wrong Argument Type",
42  "Wrong MP Node Type",
43  "Required Annot Skip",
44  "Wrong Union Discriminator",
45  "Unknown Coefficient Domain Specifications",
46};
47
48
49static mpsr_Status_t mpsr_errno = mpsr_Success;
50static mpsr_MP_errno = MP_Failure;
51
52mpsr_Status_t mpsr_SetError(mpsr_Status_t error)
53{
54  mpsr_errno = error;
55  return error;
56}
57
58mpsr_Status_t mpsr_SetError(MP_Link_pt link)
59{
60  mpsr_SetError(mpsr_MP_Failure);
61  mpsr_MP_errno = link->errno;
62  return mpsr_MP_Failure;
63}
64
65void mpsr_PrintError(mpsr_Status_t error, MP_Link_pt link)
66{
67  if (error != mpsr_Success)
68  {
69    if (error == mpsr_MP_Failure)
70      Werror("%s : %s", mpsr_errlist[error],
71             (link != NULL ? MP_ErrorStr(link) :
72              (mpsr_MP_errno < MP_MaxError ? MP_errlist[mpsr_MP_errno] :
73               "Unknown MP error")));
74    else if (error == mpsr_MPT_Failure)
75      Werror("%s : %s", mpsr_errlist[error],
76             ((MPT_errno == MPT_MP_Failure && link != NULL) ?
77              MP_ErrorStr(link) : MPT_ErrorStr(MPT_errno)));
78    else Werror("MP<->Singular interface error : %s",
79                (mpsr_errno < mpsr_MaxError ? mpsr_errlist[mpsr_errno] :
80                 "Unknown mpsr error"));
81  }
82 
83}
84void mpsr_PrintError(MP_Link_pt link)
85{
86  mpsr_PrintError(mpsr_errno, link);
87}
88
89void mpsr_PrintError(mpsr_Status_t error)
90{
91  mpsr_PrintError(error, NULL);
92}
93
94
95void mpsr_PrintError()
96{
97  mpsr_PrintError(mpsr_errno, NULL);
98}
99
100mpsr_Status_t mpsr_GetError()
101{
102  return mpsr_errno;
103}
104
105void mpsr_ClearError()
106{
107  mpsr_errno = mpsr_Success;
108}
109#endif
Note: See TracBrowser for help on using the repository browser.