1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
7 */
8
9#ifndef _MAL_EXCEPTION_H
10#define _MAL_EXCEPTION_H
11#include "mal_instruction.h"
12
13/* #define _DEBUG_EXCEPTION_ trace the exception handling */
14
15/* These are the exceptions known, adding new ones here requires to also
16 * add the "full" name to the exceptionNames array in mal_exception.c */
17enum malexception {
18 MAL=0,
19 ILLARG,
20 OUTOFBNDS,
21 IO,
22 INVCRED,
23 OPTIMIZER,
24 STKOF,
25 SYNTAX,
26 TYPE,
27 LOADER,
28 PARSE,
29 ARITH,
30 PERMD,
31 SQL
32};
33
34#define MAL_SUCCEED ((str) 0) /* no error */
35
36#define throw \
37 return createException
38#define rethrow(FCN, TMP, PRV) \
39 {if ((TMP = PRV) != MAL_SUCCEED) return(TMP);}
40
41#if !__has_attribute(__returns_nonnull__)
42#define __returns_nonnull__
43#endif
44
45mal_export str createException(enum malexception, const char *,
46 _In_z_ _Printf_format_string_ const char *, ...)
47 __attribute__((__format__(__printf__, 3, 4)))
48 __attribute__((__returns_nonnull__));
49/*FIXmal_export str createMalException(MalBlkPtr mb, int pc, enum malexception type, const char *prev, const char *format, ...);*/
50mal_export str createMalException(MalBlkPtr , int , enum malexception ,
51 _In_z_ _Printf_format_string_ const char *, ...)
52 __attribute__((__format__(__printf__, 4, 5)))
53 __attribute__((__returns_nonnull__));
54mal_export int isExceptionVariable(str nme);
55
56mal_export enum malexception getExceptionType(const char *);
57mal_export str getExceptionPlace(const char *);
58mal_export str getExceptionMessageAndState(const char *);
59mal_export str getExceptionMessage(const char *);
60mal_export void freeException(str);
61
62#include "mal_errors.h"
63#endif /* _MAL_EXCEPTION_H*/
64