[go: up one dir, main page]

File: errors.html

package info (click to toggle)
soci 2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,400 kB
  • ctags: 1,969
  • sloc: cpp: 17,658; sh: 8,749; makefile: 379
file content (73 lines) | stat: -rw-r--r-- 1,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"  http-equiv="content-type" />
  <link rel="stylesheet" type="text/css" href="style.css" />
  <title>SOCI - errors</title>
</head>

<body>
<p class="banner">SOCI - The C++ Database Access Library</p>

<h2>Errors</h2>

<p>All DB-related errors manifest themselves as exceptions of type <code>SOCIError</code>,
which is derived from <code>std::runtime_error</code>.<br />
This allows to
handle database errors within the standard exception framework:</p>

<pre class="example">
int main()
{
    try
    {
        // regular code
    }
    catch (exception const &amp;e)
    {
        cerr &lt;&lt; "Bang! " &lt;&lt; e.what() &lt;&lt; endl;
    }
}
</pre>

<div class="note">
<p><span class="note">Portability note:</span></p>
<p>The Oracle backend can also throw the instances of the <code>OracleSOCIError</code>,
which is publicly derived from <code>SOCIError</code> and has an
additional public <code>errNum_</code>
member containing the Oracle error code:</p>

<pre class="example">
int main()
{
    try
    {
        // regular code
    }
    catch (OracleSOCIError const &amp;e)
    {
        cerr &lt;&lt; "Oracle error: " &lt;&lt; e.errNum_
            &lt;&lt; " " &lt;&lt; e.what() &lt;&lt; endl;
    }
    catch (exception const &amp;e)
    {
        cerr &lt;&lt; "Some other error: " &lt;&lt; e.what() &lt;&lt; endl;
    }
}
</pre>
</div>

<table class="foot-links" border="0" cellpadding="2" cellspacing="2">
  <tr>
    <td class="foot-link-left">
      <a href="structure.html">Previous (Library structure, files and compilation)</a>
    </td>
    <td class="foot-link-right">
      <a href="basics.html">Next (Connections and simple queries)</a>
    </td>
  </tr>
</table>

<p class="copyright">Copyright &copy; 2004-2006 Maciej Sobczak, Stephen Hutton</p>
</body>
</html>