Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Jinja2 errors and OSErrors produce a clearer message #2801

Merged
merged 1 commit into from
Mar 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion mkdocs/commands/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from urllib.parse import urlsplit
from os.path import isdir, isfile, join

import jinja2.exceptions

from mkdocs.commands.build import build
from mkdocs.config import load_config
from mkdocs.exceptions import Abort
Expand Down Expand Up @@ -93,9 +95,12 @@ def error_handler(code):
log.info("Shutting down...")
finally:
server.shutdown()
except jinja2.exceptions.TemplateError:
# This is a subclass of OSError, but shouldn't be suppressed.
raise
except OSError as e: # pragma: no cover
# Avoid ugly, unhelpful traceback
raise Abort(str(e))
raise Abort(f'{type(e).__name__}: {e}')
finally:
if isdir(site_dir):
shutil.rmtree(site_dir)