~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/docs/ref/tcl/error.html

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!--$Id$-->
2
 
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
 
<!--All rights reserved.-->
4
 
<!--See the file LICENSE for redistribution information.-->
5
 
<html>
6
 
<head>
7
 
<title>Berkeley DB Reference Guide: Tcl error handling</title>
8
 
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
 
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
10
 
</head>
11
 
<body bgcolor=white>
12
 
<table width="100%"><tr valign=top>
13
 
<td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Tcl API</dl></h3></td>
14
 
<td align=right><a href="../../ref/tcl/program.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/tcl/faq.html"><img src="../../images/next.gif" alt="Next"></a>
15
 
</td></tr></table>
16
 
<p>
17
 
<h1 align=center>Tcl error handling</h1>
18
 
<p>The Tcl interfaces to Berkeley DB generally return TCL_OK on success and throw
19
 
a Tcl error on failure, using the appropriate Tcl interfaces to provide
20
 
the user with an informative error message.  There are some "expected"
21
 
failures, however, for which no Tcl error will be thrown and for which
22
 
Tcl commands will return TCL_OK.  These failures include times when a
23
 
searched-for key is not found, a requested key/data pair was previously
24
 
deleted, or a key/data pair cannot be written because the key already
25
 
exists.
26
 
<p>These failures can be detected by searching the Berkeley DB error message that
27
 
is returned.  For example, use the following to detect that an attempt
28
 
to put a record into the database failed because the key already
29
 
existed:
30
 
<p><blockquote><pre>% berkdb open -create -btree a.db
31
 
db0
32
 
% db0 put dog cat
33
 
0
34
 
% set ret [db0 put -nooverwrite dog newcat]
35
 
DB_KEYEXIST: Key/data pair already exists
36
 
% if { [string first DB_KEYEXIST $ret] != -1 } {
37
 
        puts "This was an error; the key existed"
38
 
}
39
 
This was an error; the key existed
40
 
% db0 close
41
 
0
42
 
% exit</pre></blockquote>
43
 
<p>To simplify parsing, it is recommended that the initial Berkeley DB error name
44
 
be checked; for example, <a href="../../api_c/dbc_put.html#DB_KEYEXIST">DB_KEYEXIST</a> in the previous example.
45
 
To ensure that Tcl scripts are not broken by upgrading to new releases
46
 
of Berkeley DB, these values will not change in future releases of Berkeley DB.
47
 
There are currently only three such "expected" error returns:
48
 
<p><blockquote><pre>DB_NOTFOUND: No matching key/data pair found
49
 
DB_KEYEMPTY: Nonexistent key/data pair
50
 
DB_KEYEXIST: Key/data pair already exists</pre></blockquote>
51
 
<p>Finally, sometimes Berkeley DB will output additional error information when
52
 
a Berkeley DB error occurs.  By default, all Berkeley DB error messages will be
53
 
prefixed with the created command in whose context the error occurred
54
 
(for example, "env0", "db2", and so on).  There are several ways to
55
 
capture and access this information.
56
 
<p>First, if Berkeley DB invokes the error callback function, the additional
57
 
information will be placed in the error result returned from the command
58
 
and in the errorInfo backtrace variable in Tcl.
59
 
<p>Also, the two calls to open an environment and open a database take an
60
 
option, <b>-errfile filename</b>, which sets an output file to which
61
 
these additional error messages should be written.
62
 
<p>Additionally, the two calls to open an environment and open a database
63
 
take an option, <b>-errpfx string</b>, which sets the error prefix to
64
 
the given string.  This option may be useful in circumstances where a
65
 
more descriptive prefix is desired or where a constant prefix indicating
66
 
an error is desired.
67
 
<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/tcl/program.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/tcl/faq.html"><img src="../../images/next.gif" alt="Next"></a>
68
 
</td></tr></table>
69
 
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
70
 
</body>
71
 
</html>