Use exceptions instead of sys.exit

Signed-off-by: Gowrishankar Rajaiyan <gsr@redhat.com>