move exception handling to one error function.