Skip to content

Commit

Permalink
Handle ValueError (#643)
Browse files Browse the repository at this point in the history
* Add invalid package name test

Tracking work in progress in ament/ament_index#69

Signed-off-by: Rob Clarke <[email protected]>

* Handle ValueError from get_package_prefix

Signed-off-by: Rob Clarke <[email protected]>

* Lint

Signed-off-by: Rob Clarke <[email protected]>
  • Loading branch information
rob-clarke authored Jun 4, 2021
1 parent 21b988c commit 72cd9fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ros2pkg/ros2pkg/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_package_names():
def get_prefix_path(package_name):
try:
prefix_path = get_package_prefix(package_name)
except PackageNotFoundError:
except (PackageNotFoundError, ValueError):
return None
return prefix_path

Expand Down
5 changes: 4 additions & 1 deletion ros2pkg/test/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ def test_api():
prefix_path = get_prefix_path('ros2cli')
assert os.path.isdir(prefix_path)

prefix_path = get_prefix_path('_not_existing_package_name')
prefix_path = get_prefix_path('not_existing_package_name')
assert prefix_path is None

prefix_path = get_prefix_path('invalid.package.name')
assert prefix_path is None

0 comments on commit 72cd9fb

Please sign in to comment.