Skip to content
Permalink
Browse files

Show last exception text and NIKOLA_DEBUG explanation (#2774 #2771)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 21, 2017
1 parent a54a3e1 commit cc27a4adb8925e806494d1d85d925140d2876ca4
Showing with 11 additions and 1 deletion.
  1. +11 −1 nikola/__main__.py
@@ -284,9 +284,10 @@ def load_tasks(self, cmd, opt_values, pos_args):
self.nikola.gen_tasks('post_render', "LateTask", 'Group of tasks to be executed after site is rendered.'))
signal('initialized').send(self.nikola)
except Exception:
LOGGER.error('Error loading tasks')
LOGGER.error('Error loading tasks. An unhandled exception occurred.')
if self.nikola.debug:
raise
_print_exception()
sys.exit(3)
return tasks + latetasks, DOIT_CONFIG

@@ -372,8 +373,10 @@ def run(self, cmd_args):
try:
return super(DoitNikola, self).run(cmd_args)
except Exception:
LOGGER.error('An unhandled exception occurred.')
if self.nikola.debug:
raise
_print_exception()
return 1

@staticmethod
@@ -410,5 +413,12 @@ def levenshtein(s1, s2):
return previous_row[-1]


def _print_exception():
"""Print an exception in a more friendly, shorter style."""
etype, evalue, _ = sys.exc_info()
LOGGER.error(''.join(traceback.format_exception(etype, evalue, None, limit=0, chain=False)).strip())
LOGGER.notice("To see more details, run Nikola in debug mode (set environment variable NIKOLA_DEBUG=1)")


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))

0 comments on commit cc27a4a

Please sign in to comment.
You can’t perform that action at this time.