[m-dev.] for review: handle exceptions in the ODBC interface
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Mar 21 16:35:05 AEDT 2000
> On 21-Mar-2000, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > Handle exceptions thrown by the closure passed to odbc__transaction.
> >
> > extras/odbc/odbc.m:
> > Abort the transaction if the closure passed to odbc__transaction
> > throws an exception, and rethrow the exception to the caller.
> ...
> > + /*
> > + ** There was a Mercury exception -- abort the transaction.
> > + */
> > + DEBUG(printf(
> > + ""Mercury exception in transaction: aborting\\n""));
> > + SQLTransact(odbc_env_handle, odbc_connection, SQL_ROLLBACK);
>
> Here you are ignoring the return value of SQLTransact().
> That is probably a reasonable thing to do under the circumstances,
> but you should document this, at least by adding a cast to (void)
> in front of that call, and perhaps also with a comment in the source.
--- odbc.m 2000/03/21 05:19:16 1.2
+++ odbc.m 2000/03/21 05:19:35
@@ -543,10 +543,14 @@
/*
** There was a Mercury exception -- abort the transaction.
+ ** The return value of the call to SQLTransact() is
+ ** ignored because the caller won't look at the result --
+ ** it will just rethrow the exception.
*/
DEBUG(printf(
""Mercury exception in transaction: aborting\\n""));
- SQLTransact(odbc_env_handle, odbc_connection, SQL_ROLLBACK);
+ (void) SQLTransact(odbc_env_handle,
+ odbc_connection, SQL_ROLLBACK);
}
*Status = SQL_SUCCESS;
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list