diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 05:06:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-23 05:06:46 +0000 |
commit | 92240acb5cc600eec60624ece9ed4b9ec43b386f (patch) | |
tree | 13328d0de4f37030731a96e25749563742fce0cb /asynceapi/errors.py | |
parent | Adding upstream version 0.14.0. (diff) | |
download | anta-92240acb5cc600eec60624ece9ed4b9ec43b386f.tar.xz anta-92240acb5cc600eec60624ece9ed4b9ec43b386f.zip |
Adding upstream version 0.15.0.upstream/0.15.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'asynceapi/errors.py')
-rw-r--r-- | asynceapi/errors.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/asynceapi/errors.py b/asynceapi/errors.py new file mode 100644 index 0000000..614427a --- /dev/null +++ b/asynceapi/errors.py @@ -0,0 +1,42 @@ +# Copyright (c) 2024 Arista Networks, Inc. +# Use of this source code is governed by the Apache License 2.0 +# that can be found in the LICENSE file. +# Initially written by Jeremy Schulman at https://github.com/jeremyschulman/aio-eapi +"""asynceapi module exceptions.""" + +from __future__ import annotations + +from typing import Any + +import httpx + + +class EapiCommandError(RuntimeError): + """ + Exception class for EAPI command errors. + + Attributes + ---------- + failed: the failed command + errmsg: a description of the failure reason + errors: the command failure details + passed: a list of command results of the commands that passed + not_exec: a list of commands that were not executed + """ + + def __init__(self, failed: str, errors: list[str], errmsg: str, passed: list[str | dict[str, Any]], not_exec: list[dict[str, Any]]) -> None: # noqa: PLR0913 # pylint: disable=too-many-arguments + """Initialize for the EapiCommandError exception.""" + self.failed = failed + self.errmsg = errmsg + self.errors = errors + self.passed = passed + self.not_exec = not_exec + super().__init__() + + def __str__(self) -> str: + """Return the error message associated with the exception.""" + return self.errmsg + + +# alias for exception during sending-receiving +EapiTransportError = httpx.HTTPStatusError |