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

Improve error reporting by adding file locations to exceptions #823

Open
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions launch/launch/actions/include_launch_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import Iterable, Sequence
from typing import List
from typing import Optional
from typing import Text
from typing import Tuple
from typing import Union

Expand Down Expand Up @@ -160,8 +161,12 @@ def execute(self, context: LaunchContext) -> List[LaunchDescriptionEntity]:
perform_substitutions(context, normalize_to_list_of_substitutions(arg_name))
for arg_name, arg_value in self.launch_arguments
]
declared_launch_arguments = (
launch_description.get_launch_arguments_with_include_launch_description_actions())
try:
declared_launch_arguments = (
launch_description.get_launch_arguments_with_include_launch_description_actions())
except Exception as exc:
exc.add_note(f'while executing {self.describe()}')
raise
for argument, ild_actions in declared_launch_arguments:
if argument._conditionally_included or argument.default_value is not None:
continue
Expand All @@ -183,3 +188,7 @@ def execute(self, context: LaunchContext) -> List[LaunchDescriptionEntity]:

# Set launch arguments as launch configurations and then include the launch description.
return [*set_launch_configuration_actions, launch_description]

def __repr__(self) -> Text:
"""Return a description of this IncludeLaunchDescription as a string."""
return f'IncludeLaunchDescription({self.__launch_description_source.location})'
12 changes: 8 additions & 4 deletions launch/launch/launch_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,14 @@ def process_entities(entities, *, _conditional_inclusion, nested_ild_actions=Non
if next_nested_ild_actions is None:
next_nested_ild_actions = []
next_nested_ild_actions.append(entity)
process_entities(
entity.describe_sub_entities(),
_conditional_inclusion=False,
nested_ild_actions=next_nested_ild_actions)
try:
process_entities(
entity.describe_sub_entities(),
_conditional_inclusion=False,
nested_ild_actions=next_nested_ild_actions)
except Exception as e:
e.add_note(f'processing sub-entities of entity: {entity}')
raise
for conditional_sub_entity in entity.describe_conditional_sub_entities():
process_entities(
conditional_sub_entity[1],
Expand Down
3 changes: 3 additions & 0 deletions launch/launch/substitutions/path_join_substitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ def perform(self, context: LaunchContext) -> Text:
"""Perform the substitution by retrieving the local variable."""
performed_substitutions = [sub.perform(context) for sub in self.__substitutions]
return os.path.join(*performed_substitutions)

def __repr__(self):
return self.describe()