Centralize error handling in register