1 //   Copyright (c)  1997-2006  John Abbott
2 
3 //   This file is part of the source of CoCoALib, the CoCoA Library.
4 
5 //   CoCoALib is free software: you can redistribute it and/or modify
6 //   it under the terms of the GNU General Public License as published by
7 //   the Free Software Foundation, either version 3 of the License, or
8 //   (at your option) any later version.
9 
10 //   CoCoALib is distributed in the hope that it will be useful,
11 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //   GNU General Public License for more details.
14 
15 //   You should have received a copy of the GNU General Public License
16 //   along with CoCoALib.  If not, see <http://www.gnu.org/licenses/>.
17 
18 #include <stdio.h>
19 #include "jaaerror.h"
20 
21 int LAST_ERROR = 0;    /* 0 means no error */
22 int PRINT_ERRORS = 1;  /* zero means don't print, non-zero means print */
23 
24 
25 static const char *err_msg[] =
26 {
27   "no error has occurred",
28   "division by zero",
29   "argument to FFctor not an odd prime or greater than 65535",
30   "memory space exhausted",
31   "maximum deg in destination polynomial too low",
32   "unspecified error",
33   "zero to power zero",
34   "DUPFFdiv4, illegal arg sharing",
35   "DUPZfactors_add: not enough space",
36   "DUPIsubtract_product: illegal arg sharing",
37   "DUPZreverse: polynomial has zero constant coefficient",
38   "Hensel error: factors not coprime",
39   "DUPFFexpt3mod: power not positive",
40   "Illegal argument aliasing",
41   "Matrix problem (wrong size)",
42   "CRA failed: prime list exhausted"
43 };
44 
45 static int MAXERRCODE = 15;
46 
47 
JERROR(int errcode)48 void JERROR(int errcode)
49 {
50   LAST_ERROR = errcode;
51   if (!PRINT_ERRORS) return;
52   if (errcode < 1 || errcode > MAXERRCODE)
53     fprintf(stderr, "ERROR: unknown error number, %d\n", errcode);
54   else
55     fprintf(stderr, "ERROR: %s\n", err_msg[errcode]);
56 
57 }
58