Discussion:
[Erp5-dev] exception handling in activities
bartek
2007-03-12 17:07:23 UTC
Permalink
Hello

I observed a behaviour that I did not expect: a method called from
unittest via portal_activities should raise an exception, but it doesn't
- but activities say they can not execute it, and the test fails with
"tic is looping forever" message. The big question is, what happens to
the exception, and how do the activities know the method failed???

Specifically, the method went like

...
self.log('before edit')
self.edit(**kw)
self.log('after edit')
...

Logs said "before edit", and nothing more. Doing like:

try:
...
self.log('before edit')
self.edit(**kw)
self.log('after edit')
...
except Exception, e:
self.log(e)
raise e

didn't help - still nothing in the logs, but activities failed. I had to
use a crystal ball to figure out what was wrong - turned out that kw
contained an illegal argument. But if so, then an exception should have
been raised - so what happened to it? Was it caught somewhere else?
Needless to say, it is debugging nightmare...

Bartek
Jérôme Perrin
2007-03-13 07:48:05 UTC
Permalink
Post by bartek
still nothing in the logs, but activities failed
`runUnitTest --email_from_address=your_mail_address` will send activity
failures to your mail address (if you're on a "real" site, go to portal's
properties). Still this is far from perfect, and probably
ERP5TypeTestCase.tic should show the traceback of failing activities.

J?rome
bartek
2007-03-13 13:09:08 UTC
Permalink
Post by Jérôme Perrin
Post by bartek
still nothing in the logs, but activities failed
`runUnitTest --email_from_address=your_mail_address` will send activity
failures to your mail address (if you're on a "real" site, go to portal's
properties). Still this is far from perfect, and probably
ERP5TypeTestCase.tic should show the traceback of failing activities.
Probably, yes. That's what one would expect - that if an exception is
raised, it should show up somewhere. I lost two days because it just
doesn't.

Anyway, I'm curious - what happens to the exception? It is raised,
that's for sure - but it doesn't reach the caller. Is it trapped in the
meantime, or what? Or is it handled some other way? How?

B.
Post by Jérôme Perrin
J?rome
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://erp5.org/mailman/listinfo/erp5-dev
Jérôme Perrin
2007-03-13 18:31:23 UTC
Permalink
Post by bartek
Anyway, I'm curious
I'm also curious :)
We discovered a case where the message was put in processing_node =-2 without
logging the error. Maybe with r13404 you will have something in your log
files ?

J?rome

Jean-Paul Smets
2007-03-13 08:11:33 UTC
Permalink
BTW, self.log is deprecated.

Either use LOG or Log.log

JPS.
Post by bartek
Hello
I observed a behaviour that I did not expect: a method called from
unittest via portal_activities should raise an exception, but it doesn't
- but activities say they can not execute it, and the test fails with
"tic is looping forever" message. The big question is, what happens to
the exception, and how do the activities know the method failed???
Specifically, the method went like
...
self.log('before edit')
self.edit(**kw)
self.log('after edit')
...
...
self.log('before edit')
self.edit(**kw)
self.log('after edit')
...
self.log(e)
raise e
didn't help - still nothing in the logs, but activities failed. I had to
use a crystal ball to figure out what was wrong - turned out that kw
contained an illegal argument. But if so, then an exception should have
been raised - so what happened to it? Was it caught somewhere else?
Needless to say, it is debugging nightmare...
Bartek
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://erp5.org/mailman/listinfo/erp5-dev
--
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 62 05 76 14
Nexedi: Consulting and Development of Libre / Open Source Software
http://www.nexedi.com
ERP5: Libre/ Open Source ERP Software for small and medium companies
http://www.erp5.org
Rentalinux: Desktop Linux Server
http://www.rentalinux.com
Loading...