Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1/*
2 ERROR.h - Lumiera Error handling interface (C-style)
3
4 Copyright (C)
5 2008, Christian Thaeter <ct@pipapo.org>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
34#ifndef LUMIERA_ERROR_H
35#define LUMIERA_ERROR_H
36
37#ifdef __cplusplus
38extern "C" {
39#elif 0
40} /* fixes broken emacs indenting */
41#endif
42
43
44#include <nobug.h>
45#include <stdlib.h>
46
47
48typedef const char* lumiera_err;
49
54#define LUMIERA_DIE(err) \
55 do { NOBUG_ERROR(NOBUG_ON, "Fatal Error: %s ", strchr(LUMIERA_ERROR_##err, ':')); abort(); } while(0)
56
62#define LUMIERA_ERROR_DECLARE(err) \
63extern lumiera_err const LUMIERA_ERROR_##err
64
71#define LUMIERA_ERROR_DEFINE(err, msg) \
72lumiera_err const LUMIERA_ERROR_##err = "LUMIERA_ERROR_" #err ":" msg
73
82#define LUMIERA_ERROR_SET(flag, err, extra) \
83 do { \
84 const char* theextra = extra; \
85 ERROR (flag, "%s%s%s", strchr(LUMIERA_ERROR_##err, ':')+1, theextra?": ":"", theextra?theextra:""); \
86 lumiera_error_set(LUMIERA_ERROR_##err, theextra); \
87 } while (0)
88
97#define LUMIERA_ERROR_SET_ALERT(flag, err, extra) \
98 do { \
99 const char* theextra = extra; \
100 ALERT (flag, "%s%s%s", strchr(LUMIERA_ERROR_##err, ':')+1, theextra?": ":"", theextra?theextra:""); \
101 lumiera_error_set(LUMIERA_ERROR_##err, theextra); \
102 } while (0)
103
112#define LUMIERA_ERROR_SET_CRITICAL(flag, err, extra) \
113 do { \
114 const char* theextra = extra; \
115 CRITICAL (flag, "%s%s%s", strchr(LUMIERA_ERROR_##err, ':')+1, theextra?": ":"", theextra?theextra:"");\
116 lumiera_error_set(LUMIERA_ERROR_##err, theextra); \
117 } while (0)
118
127#define LUMIERA_ERROR_SET_WARNING(flag, err, extra) \
128 do { \
129 const char* theextra = extra; \
130 WARN (flag, "%s%s%s", strchr(LUMIERA_ERROR_##err, ':')+1, theextra?": ":"", theextra?theextra:""); \
131 lumiera_error_set(LUMIERA_ERROR_##err, theextra); \
132 } while (0)
133
143lumiera_error_set (lumiera_err nerr, const char* extra);
144
149const char*
151
159lumiera_error (void);
160
161
170lumiera_error_peek (void);
171
172
180int
182
183
184/*
185 predefined errors
186*/
189
190#ifdef __cplusplus
191} /* extern "C" */
192#endif
193#endif /* LUMIERA_ERROR_H */
lumiera_err lumiera_error_peek(void)
Check current error state without clearing it Please avoid this function and use lumiera_error() if p...
const char * lumiera_error_extra(void)
Query the extra context for the last error.
lumiera_err lumiera_error(void)
Get and clear current error state.
const char * lumiera_err
Definition error.h:48
lumiera_err lumiera_error_set(lumiera_err nerr, const char *extra)
Set error state for the current thread.
Definition error-state.c:96
int lumiera_error_expect(lumiera_err expected)
Expect some error Check that the current error state matches some expectation, if true then the error...
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Definition error.h:62
const_LList llist_cmpfn void * extra
Definition llist.h:580