Jim Starkey wrote:
> Mats Kindahl wrote:

[snip]

>> There is a class, std::exception, and it is wise to do things in the
>> same way as
>> the standard: no more "well, we handle exceptions in different ways
>> depending on
>> if it is our own exceptions or a standard library exception."
>>   
> Mats, the reason not to use std::exception is that a SQL exception needs
> more context.  An exception should contain:
> 
>    * Default text for exception
>    * A unique error number (to allow translation of text)
>    * Standard conforming SQLCODE
>    * Other API directed goodies

The entire point of having inheritance is to be able to add such things by
inheriting from the existing exception class, but if you inherit from
std::exception, you have a catch-all (in the event that you should need one) for
all exceptions.

> I do agree that a SQL engine should try to restrict itself to a single
> type, though layering considerations may make this impossible (not an
> issue, I believe, in drizzle).  In any case, depending on exception
> handling to correctly interpret a type hierarchy of exception classes is
> just asking for trouble.

Exception handling does not consider the hierarchy, it just tests the handlers
in order to find a match, so:

try {
  throw Derived();
}
catch (Base& ex) {
   cout << "Base class catched" << endl;
}
catch (Derived& ex) {
   cout << "Derived class catched" << endl;
}

will print "Base class catched".

Just my few cents,
Mats Kindahl
-- 
Mats Kindahl
Lead Software Developer
Replication Team
MySQL AB, www.mysql.com
begin:vcard
fn:Mats Kindahl
n:Kindahl;Mats
org:Sun Microsystems
adr;quoted-printable:;;Tegv=C3=A4gen 3;Storvreta;SE;74334;Sweden
email;internet:[email protected]
title:Lead Replication Software Developer
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help   : https://help.launchpad.net/ListHelp

Reply via email to