1 /*
2  *  gretl -- Gnu Regression, Econometrics and Time-series Library
3  *  Copyright (C) 2001 Allin Cottrell and Riccardo "Jack" Lucchetti
4  *
5  *  This program 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  *  This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef GRETL_ERRORS_H
21 #define GRETL_ERRORS_H
22 
23 typedef enum {
24     E_DATA = 2,
25     E_SINGULAR,     /* 3 */
26     E_DF,           /* 4 */
27     E_ZERO,         /* 5 */
28     E_TSS,          /* 6 */
29     E_ESS,          /* 7 */
30     E_NOTIMP,       /* 8 */
31     E_UNSPEC,       /* 9 */
32     E_PDWRONG,     /* 10 */
33     E_FOPEN,       /* 11 */
34     E_ALLOC,       /* 12 */
35     E_EQN,         /* 13 */
36     E_UNKVAR,      /* 14 */
37     E_ARGS,        /* 15 */
38     E_OLSONLY,     /* 16 */
39     E_INVARG,      /* 17 */
40     E_PARSE,       /* 18 */
41     E_NOVARS,      /* 19 */
42     E_NOOMIT,      /* 20 */
43     E_NOADD,       /* 21 */
44     E_ADDDUP,      /* 22 */
45     E_LOGS,        /* 23 */
46     E_SQUARES,     /* 24 */
47     E_LAGS,        /* 25 */
48     E_SQRT,        /* 26 */
49     E_HIGH,        /* 27 */
50     E_OBS,         /* 28 */
51     E_NOCONST,     /* 29 */
52     E_BADSTAT,     /* 30 */
53     E_NOMERGE,     /* 31 */
54     E_NOCONV,      /* 32 */
55     E_CANCEL,      /* 33 */
56     E_MISSDATA,    /* 34 */
57     E_NAN,         /* 35 */
58     E_NONCONF,     /* 36 */
59     E_TYPES,       /* 37 */
60     E_BADOPT,      /* 38 */
61     E_NOIDENT,     /* 39 */
62     E_EXTERNAL,    /* 40 */
63     E_TOOLONG,     /* 41 */
64     E_NODATA,      /* 42 */
65     E_NOTPD,       /* 43 */
66     E_JACOBIAN,    /* 44 */
67     E_TOOFEW,      /* 45 */
68     E_FNEST,       /* 46 */
69     E_FUNCERR,     /* 47 : error set by function writer */
70     E_STOP,        /* 48 : user aborted execution */
71     E_BADCATCH,    /* 49 : "catch" used where it's not valid */
72     E_CMPLX,       /* 50 : complex arguments/operands not supported */
73     E_MIXED,       /* 51 : mixed complex/real operands not supported */
74     E_DB_DUP,      /* 52 : duplicate vars found when saving to database */
75     E_OK,          /* 53 : not really an error */
76     E_MAX          /* 54 */
77 } GretlError;
78 
79 enum gretl_warning_codes {
80     W_GRADIENT = 1,
81     W_GENMISS,     /* 2 */
82     W_GENNAN,      /* 3 */
83     W_MAX          /* 4 */
84 };
85 
86 void errmsg (int err, PRN *prn);
87 
88 void warnmsg (PRN *prn);
89 
90 const char *errmsg_get_with_default (int err);
91 
92 const char *gretl_errmsg_get (void);
93 
94 const char *gretl_warnmsg_get (void);
95 
96 char *maybe_save_gretl_errmsg (int err);
97 
98 void gretl_errmsg_set (const char *str);
99 
100 void gretl_errmsg_append (const char *str, int err);
101 
102 void gretl_errmsg_ensure (const char *str);
103 
104 void gretl_warnmsg_set (const char *str);
105 
106 void gretl_errmsg_sprintf (const char *fmt, ...);
107 
108 void gretl_errmsg_sprintf_replace (const char *fmt, ...);
109 
110 void gretl_warnmsg_sprintf (const char *fmt, ...);
111 
112 char *gretl_strerror (int errnum);
113 
114 void gretl_errmsg_set_from_errno (const char *s, int errnum);
115 
116 int gretl_error_clear (void);
117 
118 void set_gretl_alarm (int val);
119 
120 void set_gretl_errno (int err);
121 
122 void set_gretl_warning (int w);
123 
124 int get_gretl_errno (void);
125 
126 int check_gretl_errno (void);
127 
128 int check_gretl_warning (void);
129 
130 int gretl_error_is_fatal (void);
131 
132 int gretl_errmsg_is_set (void);
133 
134 int invalid_field_error (const char *s);
135 
136 #endif /* GRETL_ERRORS_H */
137