[Nitro] transaction exception logging

Tim Larson tim at keow.org
Fri Jan 6 15:30:20 EST 2006


On Mon, Dec 26, 2005 at 12:31:55PM +0200, George Moschovitis wrote:
> Ok, will consider this, any other opinions?
> 
> -g.

Thanks for the patch:
  Fri Dec 30 13:53:26 EET 2005  George Moschovitis <gm at navel.gr>
    * Better handling of errors on transactions. [timlarson]

Would you consider adding "raise ex" after the rollback,
for the reason mentioned below (for handling exceptions)?
The application may (and mine does) want to have its own
exception handling outside of the transaction, and this
is currently blocked because the transaction swallows the
exception, making it look like it never happened and
losing any information contained in the exception.

--Tim Larson

> 
> On 12/23/05, Tim Larson <tim at keow.org> wrote:
> > In og/lib/og/store.rb "def transaction", why is there all
> > that logging code present?  It make it harder to find the
> > error location than a simple rollback and re-raising of
> > the exception would.  Also it makes test case output for
> > expected failures be unnecessarily verbose and redundant,
> > and the lack of re-raising the exception makes it difficult
> > to test when and if the right exceptions are being raised
> > by the code being tested.
> >
> > I am recommending:
> >
> >   def transaction(&block)
> >     begin
> >       start
> >       yield(self)
> >       commit
> >     rescue => ex
> >       #Logger.error 'Erro
> >       #Logger.error ex
> >       #Logger.error ex.ba
> >       rollback
> >       raise ex
> >     end
> >   end
> >
> > --Tim Larson



More information about the Nitro-general mailing list