/*@observer@*/ const char *gras_error_name(gras_error_t errcode);
-#define TRY(a) if ((errcode=a) != no_error) return errcode
+#define TRY(a) do { \
+ if ((errcode=a) != no_error) { \
+ fprintf (stderr, "%s:%d: '%s' error raising...\n", \
+ __FILE__,__LINE__, \
+ gras_error_name(errcode)); \
+ return errcode; \
+ } } while (0)
+
#define TRYCATCH(a,b) if ((errcode=a) != no_error && errcode !=b) return errcode
#define TRYFAIL(a) do { \
if ((errcode=a) != no_error) { \
- fprintf(stderr,"Got '%s' error !\n", \
+ fprintf(stderr,"%s:%d: Got '%s' error !\n", \
+ __FILE__,__LINE__, \
gras_error_name(errcode)); \
fflush(stdout); \
abort(); \
} \
} while(0)
+#if 0
#define _GRAS_ERR_PRE do { \
void *_gs_array[30]; \
size_t _gs_size= backtrace (_gs_array, 30); \
return code; \
} while (0)
+#else
+#define _GRAS_ERR_PRE do {
+#define _GRAS_ERR_POST(code) \
+ return code; \
+} while (0)
+#endif
#define RAISE0(code,fmt) _GRAS_ERR_PRE \
fprintf(stderr,"%s:%d:%s: " fmt "\n", \
#define RAISE_MALLOC RAISE0(malloc_error,"Malloc error")
#define RAISE_IMPOSSIBLE RAISE0(unknown_error,"The Impossible did happen")
+#define RAISE_UNIMPLEMENTED RAISE1(unknown_error,"Function %s unimplemented",__FUNCTION__)
#define gras_abort abort