raising exception instead of application exit on error

- changed all exit usages to raise exceptions