Replaces error throws with exit codes