FNFT
Loading...
Searching...
No Matches
fnft__errwarn.h
Go to the documentation of this file.
1/*
2* This file is part of FNFT.
3*
4* FNFT is free software; you can redistribute it and/or
5* modify it under the terms of the version 2 of the GNU General
6* Public License as published by the Free Software Foundation.
7*
8* FNFT is distributed in the hope that it will be useful,
9* but WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* Contributors:
17* Sander Wahls (TU Delft) 2017-2018, 2023.
18*/
19
27#ifndef FNFT__ERRWARN_H
28#define FNFT__ERRWARN_H
29
30#include "fnft_errwarn.h"
31
36#define FNFT__WARN(msg) fnft__warn_aux(__func__, __LINE__, msg);
37
42#define FNFT__E_NOMEM FNFT__ERRMSG(FNFT_EC_NOMEM, "Out of memory.")
43
48#define FNFT__E_INVALID_ARGUMENT(name) FNFT__ERRMSG(FNFT_EC_INVALID_ARGUMENT, FNFT__E_INVALID_ARGUMENT_(name))
49
57#define FNFT__E_SUBROUTINE(ec) FNFT__ERRMSG(-abs(ec), "Subroutine failure.")
58
63#define FNFT__E_DIV_BY_ZERO FNFT__ERRMSG(FNFT_EC_DIV_BY_ZERO, "Division by zero.")
64
69#define FNFT__E_TEST_FAILED FNFT__ERRMSG(FNFT_EC_TEST_FAILED, "Test failed.")
70
75#define FNFT__E_OTHER(msg) FNFT__ERRMSG(FNFT_EC_OTHER, msg)
76
82#define FNFT__E_NOT_YET_IMPLEMENTED(name,msg) FNFT__ERRMSG(FNFT_EC_NOT_YET_IMPLEMENTED, FNFT__E_NOT_YET_IMPLEMENTED_(name,msg))
83
88#define FNFT__E_SANITY_CHECK_FAILED(msg) FNFT__ERRMSG(FNFT_EC_SANITY_CHECK_FAILED, FNFT__E_SANITY_CHECK_FAILED_(msg))
89
94#define FNFT__E_ASSERTION_FAILED FNFT__ERRMSG(FNFT_EC_ASSERTION_FAILED, "Assertion failed.")
95
101#define FNFT__CHECK_RETCODE(ret_code, label) {if (ret_code!=FNFT_SUCCESS) {ret_code=FNFT__E_SUBROUTINE(ret_code);goto label;}}
102
108#define FNFT__CHECK_NOMEM(var,ret_code,label) {if (var==NULL) {ret_code=FNFT__E_NOMEM;goto label;}}
109
110#ifdef FNFT_ENABLE_SHORT_NAMES
111#define WARN(msg) FNFT__WARN(msg)
112#define E_NOMEM FNFT__E_NOMEM
113#define E_INVALID_ARGUMENT(name) FNFT__E_INVALID_ARGUMENT(name)
114#define E_SUBROUTINE(ec) FNFT__E_SUBROUTINE(ec)
115#define E_DIV_BY_ZERO FNFT__E_DIV_BY_ZERO
116#define E_TEST_FAILED FNFT__E_TEST_FAILED
117#define E_OTHER(msg) FNFT__E_OTHER(msg)
118#define E_NOT_YET_IMPLEMENTED(name,msg) FNFT__E_NOT_YET_IMPLEMENTED(name,msg)
119#define E_SANITY_CHECK_FAILED(msg) FNFT__E_SANITY_CHECK_FAILED(msg)
120#define E_ASSERTION_FAILED FNFT__E_ASSERTION_FAILED
121#define CHECK_RETCODE(ret_code,label) FNFT__CHECK_RETCODE(ret_code,label)
122#define CHECK_NOMEM(var,ret_code,label) FNFT__CHECK_NOMEM(var,ret_code,label)
123#endif
124
125/* --- Auxiliary macros and functions. Do not use directly. --- */
126
133#define FNFT__ERRMSG(ec,msg) fnft__errmsg_aux(ec, __func__, __LINE__, msg);
134
140#define FNFT__E_INVALID_ARGUMENT_(name) "Invalid argument "#name"."
141
147#define FNFT__E_NOT_YET_IMPLEMENTED_(name,msg) "Not yet implemented ("#name"). "#msg
148
154#define FNFT__E_SANITY_CHECK_FAILED_(msg) "Sanity check failed ("#msg")."
155
156
163FNFT_INT fnft__errmsg_aux(const FNFT_INT ec, const char *func,
164 const FNFT_INT line, const char *msg);
165
172void fnft__warn_aux(const char *func, const FNFT_INT line, const char *msg);
173
174#endif
Controls error messages.
int32_t FNFT_INT
Definition fnft_numtypes.h:56
FNFT_INT fnft__errmsg_aux(const FNFT_INT ec, const char *func, const FNFT_INT line, const char *msg)
void fnft__warn_aux(const char *func, const FNFT_INT line, const char *msg)