diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-25 10:22:41 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-25 10:54:49 -0700 |
commit | 7b227a6bf7eb409b4353adc430b2545166e0c4cd (patch) | |
tree | 9b82d6e3bec4596fdbbec6a7c449e00e3e19ad03 /notmuch-private.h | |
parent | 3b8e3ab666a54407f9596a53c66ba8ce623ac91d (diff) |
Add an INTERNAL_ERROR macro and use it for all internal errors.
We were previously just doing fprintf;exit at each point, but I
wanted to add file and line-number details to all messages, so it
makes sense to use a single macro for that.
Diffstat (limited to 'notmuch-private.h')
-rw-r--r-- | notmuch-private.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/notmuch-private.h b/notmuch-private.h index 53ea75f..53b4f1d 100644 --- a/notmuch-private.h +++ b/notmuch-private.h @@ -48,6 +48,20 @@ NOTMUCH_BEGIN_DECLS #define COMPILE_TIME_ASSERT(pred) ((void)sizeof(char[1 - 2*!(pred)])) +/* There's no point in continuing when we've detected that we've done + * something wrong internally (as opposed to the user passing in a + * bogus value). + * + * Note that __location__ comes from talloc.h. + */ +#define INTERNAL_ERROR(format, ...) \ + do { \ + fprintf(stderr, \ + "Internal error: " format " (%s)\n", \ + ##__VA_ARGS__, __location__); \ + exit (1); \ + } while (0) + /* Thanks to Andrew Tridgell's (SAMBA's) talloc for this definition of * unlikely. The talloc source code comes to us via the GNU LGPL v. 3. */ |