lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Wellnhofer <wellnho...@aevum.de>
Subject Re: [lucy-user] About error handling in Lucy C library
Date Thu, 02 Feb 2017 12:20:13 GMT
On 01/02/2017 21:53, Serkan Mulayim wrote:
> Is there any documentation on how we can use these exceptions for building safer applications?
Is there a documentation for all "classes"  which throws exceptions with the corresponding
functions? Is there any code examples on how they are used?

As Tilghman already pointed out, you can catch exceptions from C with the 
Err_trap function. You can find usage examples in the Clownfish test suite and 
in the FastUpdates cookbook entry:

     https://lucy.apache.org/docs/c/Lucy/Docs/Cookbook/FastUpdates.html

Err_trap calls a `void (*f)(void *ctx)` function pointer with a user-supplied 
context and returns the exception as Err object, or NULL on success.

Exceptions are also thrown on out-of-memory errors, so almost any method could 
throw.

> Is there any documentation on the functions which return a status (e.g 0 for success
-1 for lock error etc...) of the method as well?

There are very few methods in the public API that return a status, mostly in 
the locking code:

     https://lucy.apache.org/docs/c/Lucy/Store/Lock.html

In case of an error, you can get the Err object with Err_get_error. This 
behavior is explained in the documentation.

Nick


Mime
View raw message