📄 etiexception.htm
字号:
<html>
<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
-- Copyright 2000
-- Michael Gradman & Corwin Joy
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. Corwin Joy & Michael Gradman make no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
--
--
-- Copyright (c) 1996-1999
-- Silicon Graphics Computer Systems, Inc.
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. Silicon Graphics makes no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
--
-- Copyright (c) 1994
-- Hewlett-Packard Company
--
-- Permission to use, copy, modify, distribute and sell this software
-- and its documentation for any purpose is hereby granted without fee,
-- provided that the above copyright notice appears in all copies and
-- that both that copyright notice and this permission notice appear
-- in supporting documentation. Hewlett-Packard Company makes no
-- representations about the suitability of this software for any
-- purpose. It is provided "as is" without express or implied warranty.
--
-->
<!-- Generated by htmldoc -->
<title>ETIException</title>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">
<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>
<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p>
<h1>ETIException</h1>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td><img src="exceptions.gif" width="194" height="38"></td>
<td align="right"><img src="type.gif" width="194"
height="39"></td>
</tr>
<tr>
<td valign="top"><b>Category</b>: exceptions</td>
<td align="right" valign="top"><b>Component type</b>:
type</td>
</tr>
</table>
<h3>Description</h3>
<p><tt>ETIException</tt> is thrown when extended type information
(ETI) cannot be found for a particular data type at runtime. This
ETI is needed for <font size="2" face="Courier New">BoundIO's </font><font
size="3">and the variant classes. </font>An exception of this
type stores strings representing which method the exception was
thrown in, a message describing what error occurred, and what
actual exception type was thrown. The call to the constructor
initializes these strings. The user can extract a stringified
message with all of this information from the exception using the
standard <font size="2" face="Courier New">what() </font><font
size="3">method.</font></p>
<h3>Definition</h3>
<p>Defined in the <font size="2" face="Courier New">bind_basics.h</font><font
size="1" face="Courier New"> </font>header file. </p>
<h3>Example: Throwing and catching an ETIException ... using a
type in a DataObj that DTL's ETI mechanism can't handle</h3>
<p><code><span class="codeComment">// DTL's ETI mechanism
stores type information for all primitive types,<br>
// character arrays, and STL strings, the use of any other types,<br>
// including user-defined ones, will cause an ETIException to be
thrown<br>
// if any attempt is made to bind to such a member in a DataObj
or ParamObj<br>
// Thus, trying to bind to a DontKnowETIForMe object would cause
the offending<br>
// BCA or BPA to throw</span><br>
struct DontKnowETIForMe<br>
{<br>
int intField;<br>
double doubleField;<br>
};<br>
<br>
class TooComplexADataObj<br>
{<br>
public:<br>
int i; <span class="codeComment">// can be used by BCA</span><br>
string str; <span class="codeComment">// can be used by BCA ... STL
strings supported</span><br>
DontKnowETIForMe huh; <span class="codeComment">// can't be used ... no
ETI available</span><br>
char cstr[32]; <span class="codeComment">// can be used by BCA</span><br>
};<br>
<br>
class DefaultBCA<TooComplexADataObj><br>
{<br>
public:<br>
void operator()(BoundIOs &boundIOs,
TooComplexADataObj& rowbuf)<br>
{<br>
rowbuf["INT_VALUE"]
== rowbuf.i; <span class="codeComment">// int ... OK</span><br>
rowbuf["STRING_VALUE"]
== rowbuf.str; <span class="codeComment">// string ... OK</span><br>
rowbuf["TOO_COMPLEX"]
== rowbuf.huh; <span class="codeComment">// DontKnowETIForMe ... will throw!!!</span><br>
}<br>
};<br>
<br>
<span class="codeComment">// creating a view using TooComplexADataObj for the DataObj will
throw on the attempt to create it due to BCA call in<br>
// instantiated DBView<TooComplexADataObj> constructor</span><br>
void IWillThrow()<br>
{<br>
DBView<TooComplexADataObj> view("DB_EXAMPLE");<br>
}<br>
<br>
int main()<br>
{<br>
try<br>
{<br>
DBConnection::GetDefaultConnection.Connect("UID=example;PWD=example;DSN=example");<br>
<br>
<span class="codeComment">// call our method which
throws</span><br>
IWillThrow();<br>
}<br>
catch (RootException &ex)<br>
{<br>
/<span class="codeComment">/ can also say: cout
<< ex << endl;</span><br>
<span class="codeComment">// operator<<() for
RootExceptions just streams out what()</span><br>
cout << ex.what()
<< endl;<br>
}<br>
return 0; <span class="codeComment">// won't reach here ... exception
thrown above</span><br>
}</code></p>
<h3>Model of</h3>
<p>Standard C++ library exception.</p>
<h3>Public base classes</h3>
<p><font size="2" face="Courier New">RootException</font></p>
<h3>Members</h3>
<table border="2">
<tr>
<th>Member </th>
<th>Where defined </th>
<th>Description </th>
</tr>
<tr>
<td valign="top"><font size="2" face="Courier New">ETIException(const
string &meth, const string &err)</font></td>
<td valign="top"><tt>ETIException</tt></td>
<td valign="top">Constructor which takes a specific
method indicating where exception is being thrown from
and an error string.</td>
</tr>
<tr>
<td valign="top"><font size="2" face="Courier New">virtual
const char* what() const throw()</font></td>
<td valign="top"><tt>RootException</tt> </td>
<td valign="top">Overrides behavior in <font size="2"
face="Courier New">std::exception. </font><font size="3">Returns
a C string describing the exception, including the method
it was thrown in, the error message describing why it was
thrown, and what type of exception was thrown. Subclasses
do and may override </font><font size="2"
face="Courier New">what() </font>based on their needs. <font
size="3">See Note </font><a href="RootException.htm#1"><font
size="3">[1]</font></a><font size="3"> in </font><a
href="RootException.htm"><tt>RootException</tt></a><font
size="3">.</font></td>
</tr>
<tr>
<td valign="top"><tt>friend ostream &operator<<(ostream
&o, const RootException &ex)</tt></td>
<td valign="top"><tt>RootException</tt> </td>
<td valign="top">Note that this is a friend function, and
not a member. Streams out <font size="2"
face="Courier New">ex.what()</font><font size="3"> to </font><font
size="2" face="Courier New">o.</font><font size="3"> As </font><font
size="2" face="Courier New">what() </font><font size="3">is
virtual, the appropriate version of that method will be
called for </font><font size="2" face="Courier New">ex.</font></td>
</tr>
</table>
<h3>Notes</h3>
<p>None.</p>
<h3>See also</h3>
<p><a href="RootException.htm"><tt>RootException</tt></a>.<br>
<br>
</p>
<hr>
<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>
<p>Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -