1#
2# This file is part of pysnmp software.
3#
4# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
5# License: http://snmplabs.com/pysnmp/license.html
6#
7from pyasn1.error import PyAsn1Error
8from pysnmp.error import PySnmpError
9
10
11class SmiError(PySnmpError, PyAsn1Error):
12    pass
13
14
15class MibLoadError(SmiError):
16    pass
17
18
19class MibNotFoundError(MibLoadError):
20    pass
21
22
23class MibOperationError(SmiError):
24    def __init__(self, **kwargs):
25        self.__outArgs = kwargs
26
27    def __str__(self):
28        return '%s(%s)' % (self.__class__.__name__, self.__outArgs)
29
30    def __getitem__(self, key):
31        return self.__outArgs[key]
32
33    def __contains__(self, key):
34        return key in self.__outArgs
35
36    def get(self, key, defVal=None):
37        return self.__outArgs.get(key, defVal)
38
39    def keys(self):
40        return self.__outArgs.keys()
41
42    def update(self, d):
43        self.__outArgs.update(d)
44
45
46# Aligned with SNMPv2 PDU error-status values
47
48class TooBigError(MibOperationError):
49    pass
50
51
52class NoSuchNameError(MibOperationError):
53    pass
54
55
56class BadValueError(MibOperationError):
57    pass
58
59
60class ReadOnlyError(MibOperationError):
61    pass
62
63
64class GenError(MibOperationError):
65    pass
66
67
68class NoAccessError(MibOperationError):
69    pass
70
71
72class WrongTypeError(MibOperationError):
73    pass
74
75
76class WrongLengthError(MibOperationError):
77    pass
78
79
80class WrongEncodingError(MibOperationError):
81    pass
82
83
84class WrongValueError(MibOperationError):
85    pass
86
87
88class NoCreationError(MibOperationError):
89    pass
90
91
92class InconsistentValueError(MibOperationError):
93    pass
94
95
96class ResourceUnavailableError(MibOperationError):
97    pass
98
99
100class CommitFailedError(MibOperationError):
101    pass
102
103
104class UndoFailedError(MibOperationError):
105    pass
106
107
108class AuthorizationError(MibOperationError):
109    pass
110
111
112class NotWritableError(MibOperationError):
113    pass
114
115
116class InconsistentNameError(MibOperationError):
117    pass
118
119
120# Aligned with SNMPv2 PDU exceptions or error-status values
121
122class NoSuchObjectError(NoSuchNameError):
123    pass
124
125
126class NoSuchInstanceError(NoSuchNameError):
127    pass
128
129
130class EndOfMibViewError(NoSuchNameError):
131    pass
132
133
134# SNMP table management exceptions
135
136class TableRowManagement(MibOperationError):
137    pass
138
139
140class RowCreationWanted(TableRowManagement):
141    pass
142
143
144class RowDestructionWanted(TableRowManagement):
145    pass
146