Logo Search packages:      
Sourcecode: db4.2 version File versions  Download package

void com::sleepycat::db::Db::setErrorHandler ( DbErrorHandler  db_errcall_fcn  )  throws DbException [inline]

When an error occurs in the Berkeley DB library, an exception is thrown. In some cases, however, the errno value may be insufficient to completely describe the cause of the error, especially during initial application debugging.

The DbEnv.setErrorHandler and Db.setOnError methods are used to enhance the mechanism for reporting error messages to the application. The DbEnv.setErrorHandler and Db.setOnError methods must be called with a single object parameter. The object's class must implement the DbErrorHandler interface.

In some cases, when an error occurs, Berkeley DB will invoke the object's errcall() method with two parameters; the first is the prefix string (as previously set by Db.setErrorPrefix or DbEnv.setErrorPrefix), the second will be an error message string. It is up to this method to display the message in an appropriate manner.

Alternatively, you can use the DbEnv.setErrorStream and Db.setErrorStream methods to display the additional information via an output stream. You should not mix these approaches.

This error-logging enhancement does not slow performance or significantly increase application size, and may be run during normal operation as well as during application debugging.

For Db handles opened inside of Berkeley DB environments, calling the Db.setOnError method affects the entire environment and is equivalent to calling the DbEnv.setErrorHandler method.

The Db.setOnError method may be called at any time during the life of the application.

db_errcall_fcn the application-specified error reporting function. The function takes two parameters:

The errpfx parameter is the prefix string (as previously set by Db.setErrorPrefix or DbEnv.setErrorPrefix).

The msg parameter is the error message string.

DbException Signals that an exception of some sort has occurred.

Definition at line 886 of file Db.java.

References com::sleepycat::db::DbEnv::setErrorHandler().


Generated by  Doxygen 1.6.0   Back to index