Giter VIP home page Giter VIP logo

Comments (3)

mpgl avatar mpgl commented on June 16, 2024 1

Implemented in the development branch, will be pushed to main soon. Thanks

from dendrify.

mpgl avatar mpgl commented on June 16, 2024

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.

ckarageorgkaneen avatar ckarageorgkaneen commented on June 16, 2024

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:

from dendrify.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.