File: error.py

package info (click to toggle)
python-pysnmp4 7.1.22-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,504 kB
  • sloc: python: 33,673; makefile: 169; javascript: 4
file content (211 lines) | stat: -rw-r--r-- 3,582 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
# License: https://www.pysnmp.com/pysnmp/license.html
#
from pyasn1.error import PyAsn1Error
from pysnmp.error import PySnmpError


class SmiError(PySnmpError, PyAsn1Error):
    """Base class for all SNMP SMI-related exceptions."""

    pass


class MibLoadError(SmiError):
    """Base class for all MIB loading exceptions."""

    pass


class MibNotFoundError(MibLoadError):
    """MIB file not found."""

    pass


class MibOperationError(SmiError):
    """Base class for all MIB operation exceptions."""

    def __init__(self, **kwargs):
        """MIB operation error."""
        self.__outArgs = kwargs

    def __str__(self):
        """Return error indication as a string."""
        return f"{self.__class__.__name__}({self.__outArgs})"

    def __getitem__(self, key):
        """Return error indication value by key."""
        return self.__outArgs[key]

    def __contains__(self, key):
        """Return True if key is present in the error indication."""
        return key in self.__outArgs

    def get(self, key, defVal=None):
        """Return error indication value by key."""
        return self.__outArgs.get(key, defVal)

    def keys(self):
        """Return error indication keys."""
        return self.__outArgs.keys()

    def update(self, d):
        """Update error indication."""
        self.__outArgs.update(d)


# Aligned with SNMPv2 PDU error-status values


class TooBigError(MibOperationError):
    """Value too big."""

    pass


class NoSuchNameError(MibOperationError):
    """No such name."""

    pass


class BadValueError(MibOperationError):
    """Bad value."""

    pass


class ReadOnlyError(MibOperationError):
    """Read-only."""

    pass


class GenError(MibOperationError):
    """General error."""

    pass


class NoAccessError(MibOperationError):
    """No access."""

    pass


class WrongTypeError(MibOperationError):
    """Wrong type."""

    pass


class WrongLengthError(MibOperationError):
    """Wrong length."""

    pass


class WrongEncodingError(MibOperationError):
    """Wrong encoding."""

    pass


class WrongValueError(MibOperationError):
    """Wrong value."""

    pass


class NoCreationError(MibOperationError):
    """No creation."""

    pass


class InconsistentValueError(MibOperationError):
    """Inconsistent value."""

    pass


class ResourceUnavailableError(MibOperationError):
    """Resource unavailable."""

    pass


class CommitFailedError(MibOperationError):
    """Commit failed."""

    pass


class UndoFailedError(MibOperationError):
    """Undo failed."""

    pass


class AuthorizationError(MibOperationError):
    """Authorization error."""

    pass


class NotWritableError(MibOperationError):
    """Not writable."""

    pass


class InconsistentNameError(MibOperationError):
    """Inconsistent name."""

    pass


# Aligned with SNMPv2 PDU exceptions or error-status values


class NoSuchObjectError(NoSuchNameError):
    """No such object."""

    pass


class NoSuchInstanceError(NoSuchNameError):
    """No such instance."""

    pass


class EndOfMibViewError(NoSuchNameError):
    """End of MIB view."""

    pass


# SNMP table management exceptions


class TableRowManagement(MibOperationError):
    """Base class for all SNMP table row management exceptions."""

    pass


class RowCreationWanted(TableRowManagement):
    """Row creation wanted."""

    pass


class RowDestructionWanted(TableRowManagement):
    """Row destruction wanted."""

    pass