Better error handling for login