Debian Codegraph @

asynceapi/_errors.py

raw symbols SCIP
1 # Copyright (c) 2024-2026 Arista Networks, Inc.
2 # Use of this source code is governed by the Apache License 2.0
3 # that can be found in the LICENSE file.
4 """Exceptions for the asynceapi package."""
5
6 from __future__ import annotations
7
8 from typing import TYPE_CHECKING
9
10 if TYPE_CHECKING:
11 from asynceapi._models import EapiResponse
12
13
14 class EapiReponseError(Exception):
15 """Exception raised when an eAPI response contains errors.
16
17 Attributes
18 ----------
19 response : EapiResponse
20 The eAPI response that contains the error.
21 """
22
23 def __init__(self, response: EapiResponse) -> None:
24 """Initialize the EapiReponseError exception."""
25 self.response = response
26
27 # Build a descriptive error message
28 message = "Error in eAPI response"
29
30 if response.error_code is not None:
31 message += f" (code: {response.error_code})"
32
33 if response.error_message is not None:
34 message += f": {response.error_message}"
35
36 super().__init__(message)