Coffee-fueled-deadlines / OSRSBytes

OSRSBytes is an all-in-one Python library for Old School Runescape (OSRS) that features Item Information Lookup, OSRS Hiscores, and Grand Exchange Market information.
Eclipse Public License 2.0
49 stars 13 forks source link

Custom exceptions instead of sys.exit in Hiscores #11

Closed Haran closed 3 years ago

Haran commented 3 years ago

Issue

  1. Due to sys.exit() calls in Hiscores.py it is not possible to work with library in applications like Discord bots. One can use except SystemExit, but in this case error message will be left out of control flow (e.g. logging).

Proposition

If sys.exit() is replaced by custom exception it is possible to try-except invocation of Hiscores() and gracefully process errors

Impact on current implementation

  1. Program still will terminate, but with stacktrace and verbose information about cause of the error
  2. According to POSIX, exit code 0 means that program has been executed successfully and didn't return any errors. Taking that fact into account, uncaught exception is even more preferable because it will result exit code 1, which indicates error in runtime.