Skip to content

Commit 1c5f4fe

Browse files
committed
Refactor handler to preserve stack trace
1 parent 58e526f commit 1c5f4fe

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

awsshell/wizard.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _select_stage_prompt():
3535
else:
3636
raise KeyboardInterrupt()
3737
else:
38-
raise error
38+
return None
3939

4040

4141
class WizardException(Exception):
@@ -180,7 +180,10 @@ def execute(self):
180180
current_stage = stage.get_next_stage()
181181
except Exception as err:
182182
stages = [s.name for (s, _) in self._stage_history]
183-
(stage, index) = self._error_handler(err, stages)
183+
recovery = self._error_handler(err, stages)
184+
if recovery is None:
185+
raise
186+
(stage, index) = recovery
184187
self._pop_stages(index)
185188
current_stage = stage
186189

tests/unit/test_wizard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,5 +309,5 @@ def test_stage_exception_handler_other(error_class):
309309
prompt = mock.Mock()
310310
confirm = mock.Mock()
311311
err = error_class()
312-
with pytest.raises(error_class):
313-
stage_error_handler(err, ['stage'], confirm=confirm, prompt=prompt)
312+
res = stage_error_handler(err, ['stage'], confirm=confirm, prompt=prompt)
313+
assert res is None

0 commit comments

Comments
 (0)