Skip to content

Commit b5d6297

Browse files
committed
Tweaked the error return from Document.get_document_content() to be more helpful during development.
- Legacy-Id: 15034
1 parent 98bba9c commit b5d6297

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

ietf/doc/utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ def get_unicode_document_content(key, filename, codec='utf-8', errors='ignore'):
314314
with open(filename, 'rb') as f:
315315
raw_content = f.read().decode(codec,errors)
316316
except IOError:
317-
error = "Error; cannot read ("+key+")"
317+
if settings.DEBUG:
318+
error = "Error; cannot read ("+filename+")"
319+
else:
320+
error = "Error; cannot read ("+key+")"
318321
return error
319322

320323
return raw_content
@@ -325,7 +328,10 @@ def get_document_content(key, filename, split=True, markup=True):
325328
with open(filename, 'rb') as f:
326329
raw_content = f.read()
327330
except IOError:
328-
error = "Error; cannot read ("+key+")"
331+
if settings.DEBUG:
332+
error = "Error; cannot read ("+filename+")"
333+
else:
334+
error = "Error; cannot read ("+key+")"
329335
return error
330336

331337
# if markup:

0 commit comments

Comments
 (0)