head 1.2; access; symbols RPM_4_2_1:1.1.1.5 RPM_4_2:1.1.1.5 RPM_4_1_1:1.1.1.5 RPM_4_1:1.1.1.4 RPM_4_0_5:1.1.1.3 RPM_4_0_4:1.1.1.2 RPM_4_0_3:1.1.1.1 RPM:1.1.1; locks; strict; comment @# @; 1.2 date 2008.01.02.09.55.06; author rse; state dead; branches; next 1.1; commitid z4cpSiAhOCXk5PLs; 1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.07.23.20.45.37; author rse; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2002.01.08.00.30.11; author rse; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 2003.01.18.13.49.02; author rse; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 2001.07.23.20.09.18; author rse; state Exp; branches; next 1.1.1.5; 1.1.1.5 date 2003.01.18.14.05.00; author rse; state Exp; branches; next ; desc @@ 1.2 log @remove the ancient RPM 4.2.1 source tree copy @ text @ Berkeley DB Reference Guide: Error support

Berkeley DB Reference Guide:
Environment

PrevRefNext

Error support

Berkeley DB offers programmatic support for displaying error return values. The db_strerror interface returns a pointer to the error message corresponding to any Berkeley DB error return. This is similar to the ANSI C strerror interface, but can handle both system error returns and Berkeley DB-specific return values.

For example:

int ret;
if ((ret = dbenv->set_cachesize(dbenv, 0, 32 * 1024, 1)) != 0) {
	fprintf(stderr, "set_cachesize failed: %s\n", db_strerror(ret));
	return (1);
}

There are also two additional error interfaces: DB_ENV->err and DB_ENV->errx. These functions work like the ANSI C printf interface, taking a printf-style format string and argument list, and writing a message constructed from the format string and arguments.

The DB_ENV->err function appends the standard error string to the constructed message; the DB_ENV->errx function does not.

Error messages can be configured always to include a prefix (for example, the program name) using the DB_ENV->set_errpfx interface.

These functions provide simpler ways of displaying Berkeley DB error messages:

int ret;
dbenv->set_errpfx(dbenv, program_name);
if ((ret = dbenv->open(dbenv, home, NULL,
    DB_CREATE | DB_INIT_LOG | DB_INIT_TXN | DB_USE_ENVIRON))
    != 0) {
	dbenv->err(dbenv, ret, "open: %s", home);
	dbenv->errx(dbenv,
	    "contact your system administrator: session ID was %d",
	    session_id);
	return (1);
}

For example, if the program was called "my_app", and it tried to open an environment home directory in "/tmp/home" and the open call returned a permission error, the error messages shown would look like this:

my_app: open: /tmp/home: Permission denied.
my_app: contact your system administrator: session ID was 2

PrevRefNext

Copyright Sleepycat Software @ 1.1 log @Initial revision @ text @d1 1 a1 1 @ 1.1.1.1 log @Import: RPM 4.0.3 @ text @@ 1.1.1.2 log @Import: RPM 4.0.4 @ text @d1 1 a1 1 @ 1.1.1.3 log @Import: RPM 4.0.5 @ text @d1 2 a2 2 a3 1 d13 1 a13 1 PrevRefNext d54 1 a54 1

PrevRefNext @ 1.1.1.4 log @Import: RPM 4.1 @ text @d1 2 a2 2 d4 1 d14 1 a14 1 PrevRefNext d55 1 a55 1

PrevRefNext @ 1.1.1.5 log @Import: RPM 4.1.1 @ text @d1 2 a2 2 a3 1 d13 1 a13 1 PrevRefNext d54 1 a54 1

PrevRefNext @