Centralize and clean up error handling.