Skip to content
Snippets Groups Projects
Commit 3a5f46d2 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Factor-out the generation of "foo not available in path" comment messages into...

Factor-out the generation of "foo not available in path" comment messages into the exception that raises them.
parent 85c21007
No related branches found
No related tags found
No related merge requests found
......@@ -496,14 +496,8 @@ class File(metaclass=abc.ABCMeta):
if difference is None:
return None
difference.add_comment(
"'%s' not available in path. Falling back to binary comparison."
% e.command
e.get_comment("Falling back to binary comparison.")
)
package = e.get_package()
if package:
difference.add_comment(
"Install '%s' to get a better output." % package
)
except OutputParsingError as e:
difference = self.compare_bytes(other, source=source)
if difference is None:
......
......@@ -34,6 +34,18 @@ class RequiredToolNotFound(Exception):
def get_package(self):
return get_package_provider(self.command)
def get_comment(self, infix=''):
xs = [
"'{}' not available in path.".format(self.command),
infix,
]
x = self.get_package()
if x:
xs.append("Install '{}' to get a better output.".format(x))
return " ".join(x for x in xs if x)
class ContainerExtractionError(Exception):
def __init__(self, pathname, wrapped_exc):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment