Skip to content

Commit

Permalink
use LOGGER.error instead of naked exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed May 8, 2015
1 parent 42a4592 commit 8a430d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions nikola/plugins/command/new_post.py
Expand Up @@ -54,19 +54,22 @@ def filter_post_pages(compiler, is_post, compilers, post_pages, compiler_names):
extensions = compilers.get(compiler)
if extensions is None:
if compiler in compiler_names:
raise Exception("There is a {0} compiler available, but it's not set in your COMPILERS option.".format(compiler))
raise Exception('Unknown format {0}'.format(compiler))
LOGGER.error("There is a {0} compiler available, but it's not set in your COMPILERS option.".format(compiler))
else:
LOGGER.error('Unknown format {0}'.format(compiler))
sys.exit(1)

# Throw away the post_pages with the wrong extensions
filtered = [entry for entry in filtered if any([ext in entry[0] for ext in
extensions])]

if not filtered:
type_name = "post" if is_post else "page"
raise Exception("Can't find a way, using your configuration, to create "
LOGGER.error("Can't find a way, using your configuration, to create "
"a {0} in format {1}. You may want to tweak "
"COMPILERS or {2}S in conf.py".format(
type_name, compiler, type_name.upper()))
sys.exit(1)
return filtered[0]


Expand Down

0 comments on commit 8a430d3

Please sign in to comment.