Comments (3)
Implemented in the development branch, will be pushed to main soon. Thanks
from dendrify.
sys.exit() raises a SystemExit error (not a SystemError). So I don't think that calling sys.exit() is misleading. One advantage of exiting in this way is that you avoid getting very long error messages that include traceback calls (see https://softhints.com/how-to-print-error-message-traceback-python/). However, I do agree that my previous implementation has some room for improvements (e.g. remove prints). Thank you for your suggestion.
from dendrify.
As far as simply exiting the program is concerned, SystemExit
is not misleading. As far as user-friendliness and usability are concerned, it is. Because it is too generic, abrupt for the user and unhelpful for a developer. In the places where you use it, the errors are very specific. SystemExit
is not as informative and it is normally used for scripts (not importable modules). Also, SystemExit
is a special type of exception that won't be caught by a try: ... except Exception: ...
. Specific errors help other developers that might build on top of yours catch them, if something goes wrong, and handle them however they want. Since this a library intended to be used elsewhere and not just a little script, sys.exit()
is bad practice here.
Just raise a specific exception. That will both:
- cause the process to exit, as you intend
- notify the user with an informative backtrace (e.g. value error occured here, with a specific message)
It's up to the user of your library as to how to handle "very long error messages". E.g. if I wanna use dendrify
in a script, I can just catch your specific error, and print my own message.
See:
- https://www.reddit.com/r/Python/comments/7xdi5r/is_sysexit_bad_practice/ (discussion on this topic)
- ScilifelabDataCentre/dds_cli#78 (comment) ("Doing a hard system exit is an absolute last resort.")
- https://mail.python.org/pipermail/python-list/2016-April/857869.html ("...How rude! Instead, let the
exception bubble out...")
from dendrify.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dendrify.