dbTalk Databases Forums  

exception hierarchy

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss exception hierarchy in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Chris Frey
 
Posts: n/a

Default exception hierarchy - 07-03-2005 , 11:47 PM






Hi,

I was reading comp.lang.c++.moderated tonight, and read a post on exceptions,
and thought I'd ask for comments here, relating to mysql++.

Would it be useful to split up the exception hierarchy between
std::runtime_error and std::logic_error? This would introduce
multiple inheritance into the exception hierarchy if we wanted to
keep a common mysqlpp::Exception base class, but could be useful
for filtering exceptions on logic as well.

Is it worth the effort?

As I look at the exceptions, some of them would be a tough call.
For example, is mysqlpp::BadFieldName a runtime_error or logic_error
in a database GUI application where the user types in field names?

Still, thought it would be worth mentioning.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: exception hierarchy - 07-05-2005 , 06:07 AM






Chris Frey wrote:
Quote:
This would introduce
multiple inheritance into the exception hierarchy if we wanted to
keep a common mysqlpp::Exception base class,
The only purpose for that class is to allow someone to catch all MySQL++
exceptions in a single catch block. In documenting this change, I've
also been conflating the advantages from deriving from std::exception,
which provides a consistent interface to all exceptions. So while you
don't lose out on the latter with your proposal, you do make it more
difficult to separate the MySQL++ exceptions from C++ library exceptions.

This isn't a small concern. I know you know that MySQL++ can trigger
library exceptions, such as through vector::at(). One problem I have
with these exceptions is that -- at least with current Linux standard
C++ libraries -- the what() method just returns the name of the class
that threw it. MySQL++ exceptions have much more useful what()'s, which
can be sent directly to error logs and such. Therefore, it's likely
that real programs will treat these types of exceptions differently.

Now, if you wanted to argue in favor of adding another layer just under
Exception, parallel to the division in the Standard Library, I could be
persuaded...

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Chris Frey
 
Posts: n/a

Default Re: exception hierarchy - 07-05-2005 , 04:55 PM



On Tue, Jul 05, 2005 at 05:07:07AM -0600, Warren Young wrote:
Quote:
Now, if you wanted to argue in favor of adding another layer just under
Exception, parallel to the division in the Standard Library, I could be
persuaded...
This would be a cleaner way than what I was suggesting.
I was thinking of something like:

class BadFieldName : public mysqlpp::Exception,
public std::runtime_error

But that's kinda ugly, to say the least.

I just don't know if grouping mysql++ exceptions is really that useful
in practice, so I'll leave things as is.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: exception hierarchy - 07-06-2005 , 12:37 PM



Chris Frey wrote:

Quote:
class BadFieldName : public mysqlpp::Exception,
public std::runtime_error
You can avoid an inheritance diamond in that if Exception doesn't derive
from std::exception, which it does now.

Quote:
I just don't know if grouping mysql++ exceptions is really that useful
in practice
True, but this offers two ways to group them: as runtime vs. logic
exceptions, and as MySQL++ exceptions vs. everything else. I've already
argued in favor of the latter. The question is whether the former is
also useful.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.