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
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
Program still will terminate, but with stacktrace and verbose information about cause of the error
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.
Issue
Hiscores.py
it is not possible to work with library in applications like Discord bots. One can useexcept 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 ofHiscores()
and gracefully process errorsImpact on current implementation
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.