Commit 84f15253 authored by Jason R. Coombs's avatar Jason R. Coombs

Instead of reasing a new exception, just augment the existing exception,...

Instead of reasing a new exception, just augment the existing exception, avoiding any concerns about exception type, but still communicating the context necessary to trace the issue. Ref #537.
parent f9f7277f
...@@ -1861,8 +1861,11 @@ class FileMetadata(EmptyProvider): ...@@ -1861,8 +1861,11 @@ class FileMetadata(EmptyProvider):
with io.open(self.path, encoding='utf-8') as f: with io.open(self.path, encoding='utf-8') as f:
try: try:
metadata = f.read() metadata = f.read()
except UnicodeDecodeError as e: except UnicodeDecodeError as exc:
raise Exception("Bad utf in package: %s - %s" % (self.path, e)) # add path context to error message
tmpl = " in {self.path}"
exc.reason += tmpl.format(self=self)
raise
return metadata return metadata
raise KeyError("No metadata except PKG-INFO is available") raise KeyError("No metadata except PKG-INFO is available")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment