dtl
Category: exceptions | Component type: type |
ETIException is thrown when extended type information (ETI) cannot be found for a particular data type at runtime. This ETI is needed for BoundIO's and the variant classes. 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 what() method.
Defined in the bind_basics.h header file.
// DTL's ETI mechanism
stores type information for all primitive types,
// character arrays, and STL strings, the use of any other types,
// including user-defined ones, will cause an ETIException to be
thrown
// if any attempt is made to bind to such a member in a DataObj
or ParamObj
// Thus, trying to bind to a DontKnowETIForMe object would cause
the offending
// BCA or BPA to throw
struct DontKnowETIForMe
{
int intField;
double doubleField;
};
class TooComplexADataObj
{
public:
int i; // can be used by BCA
string str; // can be used by BCA ... STL
strings supported
DontKnowETIForMe huh; // can't be used ... no
ETI available
char cstr[32]; // can be used by BCA
};
class DefaultBCA<TooComplexADataObj>
{
public:
void operator()(BoundIOs &boundIOs,
TooComplexADataObj& rowbuf)
{
rowbuf["INT_VALUE"]
== rowbuf.i; // int ... OK
rowbuf["STRING_VALUE"]
== rowbuf.str; // string ... OK
rowbuf["TOO_COMPLEX"]
== rowbuf.huh; // DontKnowETIForMe ... will throw!!!
}
};
// creating a view using TooComplexADataObj for the DataObj will
throw on the attempt to create it due to BCA call in
// instantiated DBView<TooComplexADataObj> constructor
void IWillThrow()
{
DBView<TooComplexADataObj> view("DB_EXAMPLE");
}
int main()
{
try
{
DBConnection::GetDefaultConnection.Connect("UID=example;PWD=example;DSN=example");
// call our method which
throws
IWillThrow();
}
catch (RootException &ex)
{
// can also say: cout
<< ex << endl;
// operator<<() for
RootExceptions just streams out what()
cout << ex.what()
<< endl;
}
return 0; // won't reach here ... exception
thrown above
}
Standard C++ library exception.
RootException
Member | Where defined | Description |
---|---|---|
ETIException(const string &meth, const string &err) | ETIException | Constructor which takes a specific method indicating where exception is being thrown from and an error string. |
virtual const char* what() const throw() | RootException | Overrides behavior in std::exception. 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 what() based on their needs. See Note [1] in RootException. |
virtual const TCHAR* twhat() const throw() | RootException | Returns a pointer to a TCHAR 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 twhat() based on their needs. See Note [1] in RootException. This is useful for returning unicode error messages. See Unicode documentation. |
friend wostream &operator<<(wostream &o, const RootException &ex) | RootException | Note that this is a friend function, and not a member. Streams out ex.twhat() to o. As twhat() is virtual, the appropriate version of that method will be called for ex. |
friend ostream &operator<<(ostream &o, const RootException &ex) | RootException | Note that this is a friend function, and not a member. Streams out ex.what() to o. As what() is virtual, the appropriate version of that method will be called for ex. |
None.
Copyright © 2002, Michael Gradman and 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 and Michael Gradman make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.