41#ifndef __EST_ERROR_H__
42#define __EST_ERROR_H__
61#define MAX_ERROR_MESSAGE_LENGTH 1024
63typedef void (*EST_error_handler)(
const char *format, ...);
64extern const char *EST_error_where;
65extern char *EST_error_message;
67extern EST_error_handler EST_bug_func;
68extern EST_error_handler EST_error_func;
69extern EST_error_handler EST_sys_error_func;
70extern EST_error_handler EST_warning_func;
71extern EST_error_handler old_error_function;
72extern EST_error_handler old_sys_error_function;
74extern FILE *EST_error_stream;
75extern FILE *EST_warning_stream;
77extern jmp_buf *est_errjmp;
80extern void EST_errors_default();
81extern void EST_errors_quiet();
83void EST_quiet_error_fn(
const char *format, ...);
84void EST_quiet_sys_error_fn(
const char *format, ...);
88#define _rxp_s_(X) _rxp_S_(X)
90#define EST_bug (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
93#if defined(EST_DEBUGGING)
94#define EST_exit(N) abort()
95#define EST_error (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
97#define EST_warning (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
99#define EST_sys_error (EST_error_where = __FILE__ ", line " _rxp_s_(__LINE__)),\
100 (*EST_sys_error_func)
103#define EST_exit(N) exit(N)
104#define EST_error (EST_error_where = NULL),\
106#define EST_warning (EST_error_where = NULL),\
108#define EST_sys_error (EST_error_where = NULL),\
109 (*EST_sys_error_func)
112#define est_error_throw() (est_errjmp ? longjmp(*est_errjmp,1) : (void)EST_exit(-1))
113#define est_error() est_error_throw()
115#define CATCH_ERRORS_SKEL( INIT,CLEANUP) \
118 jmp_buf *old_errjmp = est_errjmp; \
119 int old_errjmp_ok = errjmp_ok; \
121 est_errjmp = (jmp_buf *)malloc(sizeof(jmp_buf)); \
122 int jmp_val = setjmp(*est_errjmp); \
123 if (jmp_val) { free(est_errjmp); est_errjmp = old_errjmp; errjmp_ok = old_errjmp_ok; CLEANUP} \
126#define CATCH_ERRORS() \
128 const int est_err_quiet=0; \
132#define CATCH_ERRORS_QUIET() \
134 const int est_err_quiet=1; \
135 EST_error_handler old_error_function=EST_error_func; \
136 EST_error_handler old_sys_error_function=EST_sys_error_func; \
137 EST_error_func = EST_quiet_error_fn; \
138 EST_sys_error_func = EST_quiet_sys_error_fn; \
140 EST_error_func=old_error_function; \
141 EST_sys_error_func=old_sys_error_function; \
144#define END_CATCH_ERRORS() \
146 est_errjmp = old_errjmp; \
147 errjmp_ok = old_errjmp_ok; \
148 if (est_err_quiet) { \
149 EST_error_func=old_error_function; \
150 EST_sys_error_func=old_sys_error_function; \
161enum EST_error_behaviour
167 est_errors_checked = 0,
171 est_errors_allowed = 1,
182#include "EST_String.h"
188inline const char *error_name(
const EST_String val) {
return val;}
190inline const char *error_name(
const EST_Regex val) {
return val.tostring();}
static EST_String Number(int i, int base=10)
Build string from an integer.
static EST_String FromChar(const char c)
Build string from a single character.
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)