Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better return None instead of raising exception in case of absent on AosLogicalDevices:get_logical_device #18

Open
kimcharli opened this issue Apr 19, 2022 · 0 comments

Comments

@kimcharli
Copy link
Contributor

The qe_query returns None or [] in case of not matching queries. The function below is doing raise AosAPIError in case it finds nothing. It seems to be more consistent to return None rather than raise.

design.py

class AosLogicalDevices(AosSubsystem):

    def get_logical_device(self, ld_id: str = None, ld_name: str = None):

        if ld_name:
            log_dev = self.get_all()
            if log_dev:
                for ld in log_dev:
                    if ld.get("display_name") == ld_name:
                        return ld
                raise AosAPIError(f"Logical Device {ld_name} not found")  <<<< current
                return None                                                                                <<<< proposing

        return self.rest.json_resp_get(f"/api/design/logical-devices/{ld_id}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant