Improve error handling for login operations.