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

Add exit codes that indicate what went wrong #46

Merged
merged 3 commits into from
Apr 15, 2020
Merged

Add exit codes that indicate what went wrong #46

merged 3 commits into from
Apr 15, 2020

Conversation

olsen232
Copy link
Collaborator

@olsen232 olsen232 commented Apr 15, 2020

Useful for any app built on top of sno - until now, any error caused an exit code of either 1 or 2 (except in sno diff --exit-code where all errors caused exit code 2).

See exceptions.py for a list of exit codes so far. More can be added later as needed.

SUCCESS = 0
SUCCESS_WITH_FLAG = 1
(which basically means, you sno ran diff --exit-code and there was a diff)

INVALID_ARGUMENT = 2

UNCATEGORIZED_ERROR = 10

INVALID_OPERATION = 20

NOT_YET_IMPLEMENTED = 30

NOT_FOUND = 40
NO_REPOSITORY = 41
NO_DATA = 42
NO_BRANCH = 43
NO_CHANGES = 44
NO_WORKING_COPY = 45
NO_USER = 46
NO_COMMIT = 47
NO_IMPORT_SOURCE = 48
NO_TABLE = 49

SUBPROCESS_ERROR = 128+x
(x is the error from the subprocess)

@rcoup
Copy link
Member

rcoup commented Apr 15, 2020

  1. I think sno diff --exit-code should match git diff --exit-code behaviour.

Others are all pretty minor suggestions, I don't feel strongly about them:

  1. 2 is pretty standard for bad-syntax/arguments/options IME?
  2. why not make UNCATEGORIZED_ERROR = 1?
  3. subprocess-launch-error 128 ?
  4. subprocess error: `128+(subprocess exit code)?

@olsen232
Copy link
Collaborator Author

  1. I think sno diff --exit-code should match git diff --exit-code behaviour.
    Yup this is done. 0 is same, 1 is diff.

  2. 2 is pretty standard for bad-syntax/arguments/options IME?
    Made INVALID_ARGUMENT 2

  3. why not make UNCATEGORIZED_ERROR = 1?
    This would work except in --exit-code mode, in which case, it would need a different value.
    Seems easiest just to make it the same number all the time.
    Made it 11 which is a very one-ish number.

  4. subprocess-launch-error 128 ?
    subprocess error: `128+(subprocess exit code)?
    Done

Copy link
Member

@craigds craigds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@olsen232 olsen232 merged commit 35f38ad into master Apr 15, 2020
@craigds craigds deleted the exit_codes branch April 15, 2020 23:41
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.

3 participants