Behaviour if errors during Renderer.run()

Bug #1169217 reported by Luc Saffre
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Appy
Fix Released
Medium
Luc Saffre

Bug Description

When I run appy_pod.Renderer on a template which contains buggy instructions, then the resulting file contains the tracebacks as comments. Very well. But sometimes I'd prefer appy.pod to not catch such exceptions. E.g. when I run it within a unit test suite.

Luc Saffre (luc-saffre)
Changed in appy:
assignee: nobody → Luc Saffre (luc-saffre)
Revision history for this message
Luc Saffre (luc-saffre) wrote :

Please find attached an almost-solution.
I added an option CATCH_ERRORS which is True by default, leading to the normal behaviour.
If it is False, exceptions catched during execute() or evaluateBuffer() are simply re-raised. Result is exactly what I wanted.
This is even much simpler than the first approach which we agreed upon.

One detail is missing though: CATCH_ERRORS is a global constant because I didn't find out how to access the Renderer from within a BufferAction instance. For me that's okay, but if you agree with my approach I suggest that you add a keyword option "catchErrors=True" to Renderer.__init__() and then somehow use this from within the BufferAction instead of the global CATCH_ERRORS.

Luc

Revision history for this message
Luc Saffre (luc-saffre) wrote :

I found more places where this setting CATCH_ERRORS should be used in the same way to prevent catching the exception.
Here is a new zip file with the version how I use them.
Sorry I didn't manage to produce a patch, but here is at least a list of these places:

$ ls *.py | xargs grep -n CATCH_ERRORS
actions.py:33:CATCH_ERRORS = False # 20130415
actions.py:74: if not CATCH_ERRORS: raise # 20130415
actions.py:90: if not CATCH_ERRORS: raise # 20130421
actions.py:95: if not CATCH_ERRORS: raise # 20130415
buffers.py:27: NullAction, CATCH_ERRORS
buffers.py:199: if not CATCH_ERRORS: raise
buffers.py:577: if not CATCH_ERRORS: raise

Luc

Revision history for this message
Gaëtan Delannay (gaetan-delannay) wrote :

Hi Luc,
I have implemented it with a param "raiseOnError", on the Renderer's constructor, that is False by default. I have committed this change on the Appy trunk and it will be part of Appy 0.9.0. Could you test it to check if it seems OK? The tricky thing was to ensure that, when raising an exception, the temp folder created by appy.pod is deleted (on Linux, in /tmp).
Cheers,
Gaëtan

Changed in appy:
milestone: none → 0.9.0
status: New → Fix Committed
importance: Undecided → Medium
Revision history for this message
Luc Saffre (luc-saffre) wrote :

Seems to work, but I cannot test my test case with a dev version of appy because appy has no `setup.py` (running `python setup.py test` ignores PYTHONPATH and tries to install appy 0.8.5 from PyPI instead).

Changed in appy:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.