summaryrefslogtreecommitdiff
path: root/pysnmp/proto/error.py
blob: 52e84642e6f344ff77ce3742d49d76df64114d16 (plain)
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
#
# This file is part of pysnmp software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pysnmp/license.html
#
from pyasn1.error import PyAsn1Error

from pysnmp import debug
from pysnmp.error import PySnmpError


class ProtocolError(PySnmpError, PyAsn1Error):
    pass


# SNMP v3 exceptions

class SnmpV3Error(ProtocolError):
    pass


class StatusInformation(SnmpV3Error):
    def __init__(self, **kwargs):
        SnmpV3Error.__init__(self)
        self.__errorIndication = kwargs
        debug.logger & (debug.FLAG_DSP | debug.FLAG_MP | debug.FLAG_SM | debug.FLAG_ACL) and debug.logger(
            'StatusInformation: %s' % kwargs)

    def __str__(self):
        return str(self.__errorIndication)

    def __getitem__(self, key):
        return self.__errorIndication[key]

    def __contains__(self, key):
        return key in self.__errorIndication

    def get(self, key, defVal=None):
        return self.__errorIndication.get(key, defVal)


class CacheExpiredError(SnmpV3Error):
    pass


class InternalError(SnmpV3Error):
    pass


class MessageProcessingError(SnmpV3Error):
    pass


class RequestTimeout(SnmpV3Error):
    pass