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

Replace fatal() Python function with exception #65

Open
duncanmmacleod opened this issue Feb 12, 2023 · 2 comments
Open

Replace fatal() Python function with exception #65

duncanmmacleod opened this issue Feb 12, 2023 · 2 comments

Comments

@duncanmmacleod
Copy link
Contributor

In hgettoken.py the fatal() function prints a message before halting execution with a non-zero exit code (via sys.exit), is there any objection to (me) refactoring calls to this function to instead raise standard Python exception types?

The impact on the standard command-line execution would be that a traceback is printed (currently that is not printed).

IMO, this will greatly assist the planned Python interface by providing an interface for users to catch exceptions and handle them in a bespoke manner.

@DrDaveD
Copy link
Collaborator

DrDaveD commented Feb 13, 2023

I'd rather not have the traceback in the command line, but couldn't that be eliminated by putting a try/except in main()? Oh, but I think it would be a problem in cases where it is already in a try/except block. Right?

@duncanmmacleod
Copy link
Contributor Author

Yes; if the idea is to not have long tracebacks for command-line execution, this can be handled in main() or in the if __name__ == "__main__" blocks. I'll try and put something together. Thanks Dave.

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

No branches or pull requests

2 participants