more debugging and catch md misconfigured error
This commit is contained in:
parent
946a557177
commit
1583e3be99
|
@ -49,15 +49,22 @@ def display_page(path):
|
|||
def handle_markdown_file_path(resolved_path):
|
||||
"""Given a location on disk, attempt to open it and render the markdown within."""
|
||||
try:
|
||||
logger.debug("opening resolved path '%s'", resolved_path)
|
||||
with app.open_instance_resource(resolved_path, 'r') as entry_file:
|
||||
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(entry_file.name), get_localzone())
|
||||
entry = entry_file.read()
|
||||
logger.debug("resolved path '%s' read", resolved_path)
|
||||
except OSError:
|
||||
logger.exception("resolved path '%s' could not be opened!", resolved_path)
|
||||
abort(500)
|
||||
else:
|
||||
try:
|
||||
md = init_md()
|
||||
content = Markup(md.convert(entry))
|
||||
except TypeError:
|
||||
logger.exception("error loading/rendering markdown!")
|
||||
abort(500)
|
||||
|
||||
logger.debug("file metadata: %s", md.Meta)
|
||||
|
||||
parent_navs = generate_parent_navs(resolved_path)
|
||||
|
|
|
@ -68,3 +68,12 @@ def test_favicon_override():
|
|||
response = client.get('/no-title')
|
||||
assert response.status_code == 200
|
||||
assert b'<link rel="icon" href="/media/foo.png">' in response.data
|
||||
|
||||
|
||||
def test_misconfigured_markdown_extensions():
|
||||
"""Test that a misconfigured markdown extensions leads to a 500 at render time."""
|
||||
instance_path = os.path.join(HERE, 'instance')
|
||||
app = create_app(instance_path=instance_path, test_config={'MARKDOWN_EXTENSIONS': 'WRONG'})
|
||||
client = app.test_client()
|
||||
response = client.get('/no-title')
|
||||
assert response.status_code == 500
|
||||
|
|
Loading…
Reference in New Issue