1 /*
2     This file is part of GNU APL, a free implementation of the
3     ISO/IEC Standard 13751, "Programming Language APL, Extended"
4 
5     Copyright (C) 2008-2019  Dr. Jürgen Sauermann
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __ERROR_MACROS_HH_DEFINED__
22 #define __ERROR_MACROS_HH_DEFINED__
23 
24 #include "Backtrace.hh"
25 #include "ErrorCode.hh"
26 
27 /// throw an Error with \b code only (typically a standard APL error)
28 void throw_apl_error(ErrorCode code, const char * loc)
29 #ifdef __GNUC__
30     __attribute__ ((noreturn))
31 #endif
32 ;
33 
34 #define ATTENTION         { throw_apl_error(E_ATTENTION,          LOC); }
35 #define AXIS_ERROR          throw_apl_error(E_AXIS_ERROR,           LOC)
36 #define DEFN_ERROR          throw_apl_error(E_DEFN_ERROR,           LOC)
37 #define DOMAIN_ERROR        throw_apl_error(E_DOMAIN_ERROR,         LOC)
38 #define INDEX_ERROR         throw_apl_error(E_INDEX_ERROR,          LOC)
39 #define INTERNAL_ERROR      throw_apl_error(E_INTERNAL_ERROR,       LOC)
40 #define INTERRUPT           { \
41                               throw_apl_error(E_INTERRUPT,          LOC); }
42 #define LENGTH_ERROR        throw_apl_error(E_LENGTH_ERROR,         LOC)
43 #define LIMIT_ERROR_RANK    throw_apl_error(E_SYS_LIMIT_RANK,       LOC)
44 #define LIMIT_ERROR_SVAR    throw_apl_error(E_SYS_LIMIT_SVAR,       LOC)
45 #define LIMIT_ERROR_FUNOPER throw_apl_error(E_SYS_LIMIT_FUNOPER,    LOC)
46 #define LIMIT_ERROR_PREFIX  throw_apl_error(E_SYS_LIMIT_PREFIX,     LOC)
47 #define RANK_ERROR          throw_apl_error(E_RANK_ERROR,           LOC)
48 #define SYNTAX_ERROR        throw_apl_error(E_SYNTAX_ERROR,         LOC)
49 #define LEFT_SYNTAX_ERROR   throw_apl_error(E_LEFT_SYNTAX_ERROR,    LOC)
50 #define SYSTEM_ERROR        throw_apl_error(E_SYSTEM_ERROR,         LOC)
51 #define TODO                throw_apl_error(E_NOT_YET_IMPLEMENTED,  LOC)
52 #define FIXME               {  Backtrace::show(__FILE__, __LINE__); \
53                                cleanup(false);   exit(0);           \
54                                throw_apl_error(E_THIS_IS_A_BUG,     LOC); }
55 #define VALUE_ERROR         throw_apl_error(E_VALUE_ERROR,          LOC)
56 #define VALENCE_ERROR       throw_apl_error(E_VALENCE_ERROR,        LOC)
57 #define WS_FULL           { throw_apl_error(E_WS_FULL,              LOC); }
58 
59 #endif  // __ERROR_MACROS_HH_DEFINED__
60