Skip to content

Commit 8a430d3

Browse files
committedMay 8, 2015
use LOGGER.error instead of naked exceptions
1 parent 42a4592 commit 8a430d3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

Diff for: ‎nikola/plugins/command/new_post.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,22 @@ def filter_post_pages(compiler, is_post, compilers, post_pages, compiler_names):
5454
extensions = compilers.get(compiler)
5555
if extensions is None:
5656
if compiler in compiler_names:
57-
raise Exception("There is a {0} compiler available, but it's not set in your COMPILERS option.".format(compiler))
58-
raise Exception('Unknown format {0}'.format(compiler))
57+
LOGGER.error("There is a {0} compiler available, but it's not set in your COMPILERS option.".format(compiler))
58+
else:
59+
LOGGER.error('Unknown format {0}'.format(compiler))
60+
sys.exit(1)
5961

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

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

7275

0 commit comments

Comments
 (0)