Subject Re: [IB-Architect] New API: Exceptions
Author Bill Lancaster
At 04:52 PM 6/1/00 -0400, you wrote:
>Claudio had raised the question of why pointers to SQLException
>objects were thown (and caught) rather than the objects themselves.
>The difference in the handler is:
>
> catch (SQLException exception)
> {
> ...
> }
>
>and
>
> catch (SQLException *exception)
> {
> ...
> delete exception;
> }
>
>As he pointed the, a problem with throwing a pointer is that
>somebody has to delete the throw object or suffer a memory leak
>(more about this later).


I believe Glebas was correct with

catch (SQLException &exception)
{
}

except I would add a const before SQLException. SQLException is an
abstract base class.

>case 1 above, a copy constructor would be necessary to copy
>an implementation specific subclass of SQLException to SQLException
>itself, which more or less eliminates any added value an implementation
>extension might provide. It would also make extensions of the API
>difficult and dangerous.

I'm not sure what you're saying but I "think" being responsible for
deleting a pointer is dangerous and unnecessary. In most situations you
should ALWAYS have a copy constructor, destructor, and assignment operator
or you'll get one that you don't know about.


Bill