X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch.c;h=c5fef0e800961782a1941d2999a4be6f4c6146c0;hp=46c3c63b525f626e18802772a8f0d27dd30f98f9;hb=7b227a6bf7eb409b4353adc430b2545166e0c4cd;hpb=3b8e3ab666a54407f9596a53c66ba8ce623ac91d diff --git a/notmuch.c b/notmuch.c index 46c3c63b..c5fef0e8 100644 --- a/notmuch.c +++ b/notmuch.c @@ -43,6 +43,20 @@ #include /* g_strdup_printf */ +/* 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) + #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) typedef int (*command_function_t) (int argc, char *argv[]); @@ -255,8 +269,7 @@ add_files_recursive (notmuch_database_t *notmuch, ret = status; goto DONE; default: - fprintf (stderr, "Internal error: add_message returned unexpected value: %d\n", status); - ret = status; + INTERNAL_ERROR ("add_message returned unexpected value: %d", status); goto DONE; } if (state->processed_files % 1000 == 0)