|Category: exceptions||Component type: type|
DBException is thrown when one of the database specific classes such as DBView or DBStmt encounters an error. An exception of this type stores strings representing which method the exception was thrown in and a message describing what error occurred. DBException also captures a vector of SQL errors (if any) that occurred to trigger this exception. The call to the constructor initializes these constructs (see below). The user can extract a stringified message with all of this information from the exception using the standard what() method.
Defined in the DBException.h header file.
DBStmt("THIS SQL QUERY WON'T EXECUTE").Execute(); // this *definitely* will throw DBException
// will print out ODBC msg. specifying this blatant syntax error!
// call our method which throws
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.
|DBException(const string &meth, const string &msg, DBConnection *conn, DBStmt *stmt)||DBException||Constructor which takes a specific method indicating where
exception is being thrown, an error message describing the problem encountered,
and pointers to the DBConnection and
DBStmt objects being used in the
operation that threw or NULL using the following convention:
The constructor calls a private method ShowSQLErrors() to generate the vector of any SQL errors that triggered this exception if either pointer is non-NULL.
|virtual const char* what() const throw()||DBException||Overrides behavior in RootException. Returns a C string describing the exception, including the method it was thrown in, the error message describing why it was thrown, any SQL errors that led to the exception being thrown, and what type of exception was thrown. Subclasses do and may override what() based on their needs. See Note  in RootException.|
|virtual const TCHAR* twhat() const throw()||DBException||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  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.|
|pair<string, string> GetODBCError()||DBException||Prints out a pair containing strings indicating the SQL state and description of the ODBC error that caused this exception to be thrown.|
|vector<ODBCErrorInfo> GetAllODBCErrors()||DBException||Returns a vector of all ODBC errors associated with this exception. Streaming out the returned objects (or converting to an STL string) stringifies the ODBC error information, which includes the SQL state, native error, and description.|
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.
This site written using the ORB.