Fix custom error handling so that it exits