Library Version 11.2.5.3

DB_ENV->err()
Prev | Chapter 5. The DB_ENV Handle | Next

## DB_ENV->err()

    #include <db.h>

    void
    DB_ENV->err(DB_ENV *dbenv, int error, const char *fmt, ...);

    void
    DB_ENV->errx(DB_ENV *dbenv, const char *fmt, ...);

The `DB_ENV->err()`, `DB_ENV->errx,()`, DB->err() and `DB->errx()` methods provide error-messaging functionality for applications written using the Berkeley DB library.

The DB->err() and DB_ENV->err() methods constructs an error message consisting of the following elements:

- An optional prefix string

  If no error callback function has been set using the DB_ENV->set_errcall() method, any prefix string specified using the DB_ENV->set_errpfx() method, followed by two separating characters: a colon and a <space> character.

- An optional printf-style message

  The supplied message fmt, if non-NULL, in which the ANSI C X3.159-1989 (ANSI C) printf function specifies how subsequent parameters are converted for output.

- A separator

  Two separating characters: a colon and a <space> character.

- A standard error string

  The standard system or Berkeley DB library error string associated with the error value, as returned by the db_strerror method.

This constructed error message is then handled as follows:

- If an error callback function has been set (see DB->set_errcall() and DB_ENV->set_errcall()), that function is called with two parameters: any prefix string specified (see DB->set_errpfx() and DB_ENV->set_errpfx()) and the error message.

- If a C library FILE * has been set (see DB->set_errfile() and DB_ENV->set_errfile()), the error message is written to that output stream.

- If none of these output options have been configured, the error message is written to stderr, the standard error output stream.

### Parameters

#### error

The error parameter is the error value for which the `DB_ENV->err()` and DB->err() methods will display a explanatory string.

#### fmt

The fmt parameter is an optional printf-style message to display.

### Class

DB_ENV

### See Also

Database Environments and Related Methods

Prev | Up | Next
DB_ENV->dbrename() | Home | DB_ENV->failchk()