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

Nicer error handling (Fix #2771) #2774

Merged
merged 9 commits into from May 19, 2017

Conversation

Projects
None yet
3 participants
@ralsina
Member

ralsina commented May 18, 2017

Fix #2771

  • Log before raising exceptions
  • Eat the exception at the top level unless NIKOLA_DEBUG is set.

ralsina added some commits May 18, 2017

Show outdated Hide outdated nikola/nikola.py Outdated
Show outdated Hide outdated nikola/__main__.py Outdated
Show outdated Hide outdated nikola/__main__.py Outdated
Show outdated Hide outdated nikola/__main__.py Outdated
@ralsina

This comment has been minimized.

Show comment
Hide comment
@ralsina

ralsina May 18, 2017

Member
Member

ralsina commented May 18, 2017

@@ -363,7 +371,33 @@ def run(self, cmd_args):
LOGGER.error("This command needs to run inside an "
"existing Nikola site.")
return 3
return super(DoitNikola, self).run(cmd_args)
try:

This comment has been minimized.

@Kwpolska

Kwpolska May 18, 2017

Member

Is copy-pasting code really necessary for this? Would sys.exit(1) hurt here?

@Kwpolska

Kwpolska May 18, 2017

Member

Is copy-pasting code really necessary for this? Would sys.exit(1) hurt here?

This comment has been minimized.

@ralsina

ralsina May 18, 2017

Member

Looking at it better, I would have to exit(1) in the next layer, since this run() prints the exceptions.

@ralsina

ralsina May 18, 2017

Member

Looking at it better, I would have to exit(1) in the next layer, since this run() prints the exceptions.

This comment has been minimized.

@ralsina

ralsina May 18, 2017

Member

Hell, even that won't work, it will catch exit() !!!!

@ralsina

ralsina May 18, 2017

Member

Hell, even that won't work, it will catch exit() !!!!

This comment has been minimized.

@Kwpolska

Kwpolska May 18, 2017

Member

Is that really a bare except:?

@Kwpolska

Kwpolska May 18, 2017

Member

Is that really a bare except:?

This comment has been minimized.

@ralsina

ralsina May 18, 2017

Member

Ok, fixed.

@ralsina

ralsina May 18, 2017

Member

Ok, fixed.

@ralsina

This comment has been minimized.

Show comment
Hide comment
@ralsina

ralsina May 18, 2017

Member
Member

ralsina commented May 18, 2017

@ralsina

This comment has been minimized.

Show comment
Hide comment
@ralsina

ralsina May 18, 2017

Member
Member

ralsina commented May 18, 2017

@Kwpolska

LGTM

@ralsina ralsina merged commit b657585 into master May 19, 2017

5 checks passed

codacy/pr Good work! A positive pull request.
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@ralsina ralsina deleted the fix-2771 branch May 19, 2017

Show outdated Hide outdated nikola/__main__.py Outdated
@Kwpolska

This comment has been minimized.

Show comment
Hide comment
@Kwpolska

Kwpolska May 20, 2017

Member

Hm, could we re-discuss this? Because in some cases, we will end up printing “Error loading tasks” without any explanation. How would people know what to fix? How would bug reports look?

Member

Kwpolska commented May 20, 2017

Hm, could we re-discuss this? Because in some cases, we will end up printing “Error loading tasks” without any explanation. How would people know what to fix? How would bug reports look?

@ralsina

This comment has been minimized.

Show comment
Hide comment
@ralsina

ralsina May 20, 2017

Member

In that case, clearly we are raising exceptions that we are not logging, right?

So, for that, we use NIKOLA_DEBUG=1

Also, I will check a little to see if we still have unlogging raises.

Member

ralsina commented May 20, 2017

In that case, clearly we are raising exceptions that we are not logging, right?

So, for that, we use NIKOLA_DEBUG=1

Also, I will check a little to see if we still have unlogging raises.

@Kwpolska

This comment has been minimized.

Show comment
Hide comment
@Kwpolska

Kwpolska May 20, 2017

Member

It doesn’t have to be Nikola who’s raising those exceptions. My unhelpful errors were caused by Mako syntax errors. We should at least print the exception text, and tell the user how to get full debug info.

Member

Kwpolska commented May 20, 2017

It doesn’t have to be Nikola who’s raising those exceptions. My unhelpful errors were caused by Mako syntax errors. We should at least print the exception text, and tell the user how to get full debug info.

@felixfontein

This comment has been minimized.

Show comment
Hide comment
@felixfontein

felixfontein May 20, 2017

Contributor

Yes, a bit more information would be really helpful! It can always happen that we forget to write a message at some point in the future, and then some user gets a really unhelpful error message.

Another thing which might be worth discussing: how about printing a short information text that you can get debug info with NIKOLA_DEBUG=1 in case an exception is caught? Then some more interested persons (power-users, hackers, ...) don't have to search the documentation (or the source code) first before being able to get more information.

Contributor

felixfontein commented May 20, 2017

Yes, a bit more information would be really helpful! It can always happen that we forget to write a message at some point in the future, and then some user gets a really unhelpful error message.

Another thing which might be worth discussing: how about printing a short information text that you can get debug info with NIKOLA_DEBUG=1 in case an exception is caught? Then some more interested persons (power-users, hackers, ...) don't have to search the documentation (or the source code) first before being able to get more information.

Kwpolska added a commit that referenced this pull request May 21, 2017

Show last exception text and NIKOLA_DEBUG explanation (#2774 #2771)
Signed-off-by: Chris Warrick <kwpolska@gmail.com>

ralsina added a commit that referenced this pull request May 21, 2017

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

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

Signed-off-by: Chris Warrick <kwpolska@gmail.com>

* more friendly → friendlier

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment