Skip to content

Commit

Permalink
Unify single and multiple exception cases
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Lalancette <clalancette@gmail.com>
Signed-off-by: Timon Engelke <timon.engelke@online.de>
  • Loading branch information
timonegk and clalancette committed Jul 4, 2023
1 parent 1a2637f commit 2af2fb4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions launch/launch/invalid_launch_file_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ def __init__(self, extension='', *, likely_errors=None):
'The launch file may have a syntax error, or its format is unknown'
)
else:
if len(self._likely_errors) == 1:
self._error_message = (
'Caught exception when trying to load file of format [{}]: {}'
).format(self._extension, self._likely_errors[0])
else:
self._error_message = (
'Caught multiple exceptions when trying to load file of format [{}]:'
).format(self._extension)
for error in self._likely_errors:
self._error_message += '\n - {}'.format(error)
self._error_message = (
'Caught {} when trying to load file of format [{}]:'
).format('multiple exceptions' if len(self._likely_errors) > 1 else 'exception',
self._extension)
for error in self._likely_errors:
self._error_message += '\n - {}'.format(error)

self.__cause__ = self._likely_errors[0]

Expand Down

0 comments on commit 2af2fb4

Please sign in to comment.