lib: construct compactor within try block to catch any exceptions
authorJani Nikula <jani@nikula.org>
Sun, 3 Nov 2013 12:24:42 +0000 (14:24 +0200)
committerDavid Bremner <david@tethera.net>
Wed, 6 Nov 2013 21:49:36 +0000 (17:49 -0400)
Constructors may also throw exceptions. Catch them.

lib/database.cc

index 20e5ec23f9da7fcd8d7284c96cf54324c9d32643..3dfea0f4f9e27b48de199ed539f0d58e8614b684 100644 (file)
@@ -864,7 +864,6 @@ notmuch_database_compact (const char* path,
                          notmuch_compact_status_cb_t status_cb)
 {
     void *local = talloc_new (NULL);
-    NotmuchCompactor compactor(status_cb);
     char *notmuch_path, *xapian_path, *compact_xapian_path;
     char *old_xapian_path = NULL;
     notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
@@ -910,6 +909,8 @@ notmuch_database_compact (const char* path,
     }
 
     try {
+       NotmuchCompactor compactor(status_cb);
+
        compactor.set_renumber(false);
        compactor.add_source(xapian_path);
        compactor.set_destdir(compact_xapian_path);