Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Raising FireError in __init__ is not handled properly #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fire/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def _Fire(component, args, parsed_flag_args, context, name=None):

instance = None
remaining_args = args
ExceptionRaisedByUser = None
while True:
last_component = component
initial_args = remaining_args
Expand Down Expand Up @@ -546,6 +547,11 @@ def _Fire(component, args, parsed_flag_args, context, name=None):
component_trace.AddAccessedProperty(
component, target, consumed_args, filename, lineno)

if candidate_errors:
error, initial_args = candidate_errors[0]
component_trace.AddError(error, initial_args)
ExceptionRaisedByUser = component_trace

except FireError as error:
# Couldn't access member.
candidate_errors.append((error, initial_args))
Expand All @@ -563,6 +569,8 @@ def _Fire(component, args, parsed_flag_args, context, name=None):
candidate_errors.append((error, initial_args))

if not handled and candidate_errors:
if ExceptionRaisedByUser:
return ExceptionRaisedByUser
error, initial_args = candidate_errors[0]
component_trace.AddError(error, initial_args)
return component_trace
Expand Down