Replace simple printouts + sys.exit() with proper exceptions
From Christian:
Have a look on the built-in python exceptions, if you find a proper one. Otherwise it is rather easy to create custom exceptions:
class CustomError(Exception): # can also inherit from ValueError or every other exception pass
Edited by Artem Basalaev