summaryrefslogtreecommitdiff
path: root/mammoth/docx/files.py
diff options
context:
space:
mode:
Diffstat (limited to 'mammoth/docx/files.py')
-rw-r--r--mammoth/docx/files.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/mammoth/docx/files.py b/mammoth/docx/files.py
index 7fe3a2c..ce557f6 100644
--- a/mammoth/docx/files.py
+++ b/mammoth/docx/files.py
@@ -22,7 +22,10 @@ class Files(object):
if _is_absolute(uri):
return contextlib.closing(urlopen(uri))
elif self._base is not None:
- return open(os.path.join(self._base, uri), "rb")
+ path = os.path.join(self._base, uri)
+ if not os.path.exists(path):
+ raise InvalidFileReferenceError("could not find external image '{0}' from document directory '{1}'".format(uri, self._base))
+ return open(path, "rb")
else:
raise InvalidFileReferenceError("could not find external image '{0}', fileobj has no name".format(uri))