[Xapian-devel] Re: [Xapian-commits] 7990: trunk/xapian-core/trunk/xapian-core/bin/ trunk/xapian-core/tests/harness/

Richard Boulton richard at lemurconsulting.com
Fri Mar 30 17:33:49 BST 2007


Olly Betts wrote:
> Looking at the winsock.h header in mingw, the "WSA" error codes are all
> at least 10000.  So it would be easy enough to decode real errno values
> with strerror() while handling the other values with something else.
> 
> If you're talking about sticking error codes which collide with errno
> values in the "errno" field of Xapian::Error objects, that way madness
> surely lies!  Catchers of Xapian::Error (not unreasonably) expect to be
> able to decode the errno field with strerror().  And strerror() would
> give an entirely irrelevant message if we start sticking other integer
> error codes there with overlapping ranges.

Certainly, overlapping ranges would be a mistake...  I assumed that all 
WSA error codes were non-overlapping with errno codes, but if this isn't 
the case I think the best approach would be as Olly suggests to check 
for values less than 10000 returned by socket_errno() and just append 
the formatted message to the error message held in the exception for 
these (I think messing around with translating error codes would just be 
a painful waste of time).

Would it be a good idea, though, to add a method to the base 
Xapian::Error class which decoded error codes, and returned a string. 
On unix platforms, this would just be a wrapper around strerror(), but 
on windows it could call whatever is appropriate (and not have to worry 
about freeing memory).  The codes must still be unique, though.


Incidentally, I've now finished merging Mark's patches into HEAD, so 
remote databases should now work on windows... Unless I've mucked 
something up of course, which I probably have.  However, we're certainly 
pretty close now!

-- 
Richard



More information about the Xapian-devel mailing list