[Xapian-discuss] Feature request: Determining source index of xapian-compact DatabaseError exception

Henry C. henka at cityweb.co.za
Thu Jul 14 08:43:58 BST 2011


On Thu, July 14, 2011 04:26, Olly Betts wrote:
> On Wed, Jul 13, 2011 at 02:17:03PM +0200, Henry C. wrote:
>
>> What's the possibility of something like this being added in the future?
>>
>
> Pretty likely.  There's already a ticket open for it:
>
>
> http://trac.xapian.org/ticket/329

That's good.  How about always using the 'context' argument to
Xapian::DatabaseError (context probably refers to something else, but it
certainly seems handy and is not used in these cases):

My previous sample would then become:

   string message = "Error reading block " + str(n) + ": ";
        message += strerror(errno);
-        throw Xapian::DatabaseError(message);
+        throw Xapian::DatabaseError(message, name);
    } else if (bytes_read == 0) {
        string message = "Error reading block " + str(n) + ": got end of file";
-        throw Xapian::DatabaseError(message);
+        throw Xapian::DatabaseError(message, name);


An added benefit would be a nice greppable/awkable error msg:

Database couldn't be opened for reading: DatabaseError: Error reading block 0:
got end of file (context: /indexstore/2/15/8/name.co.us.site_index/record.)

Not perfect, but a quick simple change yielding infinitely better information
compared to:

Database couldn't be opened for reading: DatabaseError: Error reading block 0:
got end of file

---

I also prefer the THROW macro idea from the bug entry, being a C-boy, but hey.
 btw, there's no easy way to get 'name' visible in the include/xapian/error.h
classes, right?

regards
h




More information about the Xapian-discuss mailing list