[lib/dialogwizard] on traite les exceptions
Ignore-this: 9a90bd32263c02b9e7f2909b2f69e301 darcs-hash:20090929132138-bd074-50fd73412bff90c7295edd03353a5752eb3b3db7.gz
This commit is contained in:
parent
de68b18b75
commit
277b1c4bd5
2 changed files with 20 additions and 9 deletions
|
@ -33,8 +33,9 @@ class Step:
|
|||
class Scenario:
|
||||
u"""This class allows us to define scenarios."""
|
||||
|
||||
def __init__(self):
|
||||
u"""empty scenario"""
|
||||
def __init__(self)
|
||||
u"""empty scenario, with an error handler (that takes an exception as
|
||||
argument)"""
|
||||
self.steps = None
|
||||
|
||||
def nest(self, step):
|
||||
|
@ -87,6 +88,8 @@ def step_scenario(step):
|
|||
def unit_scenario():
|
||||
return ( Scenario())
|
||||
|
||||
def _relance(exc): raise exc
|
||||
|
||||
class Running:
|
||||
u"""To run scenarios"""
|
||||
|
||||
|
@ -94,11 +97,12 @@ class Running:
|
|||
steps = None
|
||||
stack = None
|
||||
|
||||
def __init__(self, scenario, env = {}):
|
||||
def __init__(self, scenario, env = {}, handle = _relance):
|
||||
if not isinstance(scenario, Scenario):
|
||||
raise TypeError("Can only run Scenarios")
|
||||
accu = scenario.steps
|
||||
self.env = env
|
||||
self.handle = handle
|
||||
|
||||
# To avoid brain spots on the walls, we shall reverse the list
|
||||
# of steps.
|
||||
|
@ -157,6 +161,9 @@ class Running:
|
|||
# We can update defaults
|
||||
pass
|
||||
|
||||
except Exception, e:
|
||||
self.handle(e)
|
||||
|
||||
else:
|
||||
# Should not be called
|
||||
raise "invalid step"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue