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

nixops script: Remove top-level Exception catch-all. #924

Merged
merged 1 commit into from Jul 23, 2018

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Apr 15, 2018

Below is a small patch to fix one of my biggest gripes in using and developing nixops, and in helping colleagues and friends fix their problems.


Having this catch-all made it difficult to develop and troubleshoot
nixops.

For example, when adding a new backend and forgetting to add the
corresponding option in the .nix file, nixops would die simply
with

error: 'serverType'

which is not a good indication over what went wrong.
Specifically so because error(str(e)) removed the type of the
exception, turning KeyError: 'serverType' into just serverType.

So far, you could pass --show-trace or --debug to see
Python stack traces.
However, that requires the error to be easily reproducible
(when you see it, you have to run again with --show-trace),
making debugging of rare problems hard.

For an ops tool we should make debugging of rare/unknown
problems as easy as possible.
Consequently, this commit makes Python raise the Exception
with stack trace if we have no idea at all what the exception
type is.

The other cases (when we know what exception type it is)
remain unaffected.

Having this catch-all made it difficult to develop and troubleshoot
nixops.

For example, when adding a new backend and forgetting to add the
corresponding `option` in the `.nix` file, nixops would die simply
with

    error: 'serverType'

which is not a good indication over what went wrong.
Specifically so because `error(str(e))` removed the type of the
exception, turning `KeyError: 'serverType'` into just `serverType`.

So far, you could pass `--show-trace` or `--debug` to see
Python stack traces.
However, that requires the error to be easily reproducible
(when you see it, you have to run again with `--show-trace`),
making debugging of rare problems hard.

For an ops tool we should make debugging of rare/unknown
problems as easy as possible.
Consequently, this commit makes Python raise the `Exception`
with stack trace if we have no idea at all what the exception
type is.

The other cases (when we know what exception type it is)
remain unaffected.
@nh2
Copy link
Contributor Author

nh2 commented Apr 15, 2018

Related: #710 (basically makes what was asked there the default for those exceptions that are very likely programmer errors / nixops bugs or bugs in nixops dependencies)

@domenkozar domenkozar merged commit d4e5b77 into NixOS:master Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants