📄 error.py
字号:
""" Deprecated PySNMP 1.x compatibility interface to exception classes. Suggested by Case Van Horsen <case@ironwater.com>. Copyright 1999-2002 by Ilya Etingof <ilya@glas.net>. See LICENSE for details."""from pysnmp import errorclass PySNMPError(error.PySnmpError): """Base class for PySNMP error handlers """ pass## Generic errors#class BadArgument (PySNMPError): """Bad argument passed """ pass## BER errors#class BEREngineError (PySNMPError): """Base class for BER encapsulation exceptions """ passclass UnknownTag (BEREngineError): """Unknown BER tag """ passclass BadEncoding (BEREngineError): """Incorrect BER encoding """ passclass BadObjectID (BEREngineError): """Malformed Object ID """ passclass BadSubObjectID (BEREngineError): """Bad sub-Object ID """ passclass BadIPAddress (BEREngineError): """Bad IP address """ passclass TypeMismatch (BEREngineError): """ASN.1 data type mistmatch """ passclass OverFlow (BEREngineError): """Data item does not fit the packet """ pass## SNMP engine errors#class SNMPEngineError (PySNMPError): """Base class for SNMP engine exceptions """ passclass NotConnected (SNMPEngineError): """SNMP session is not established """ passclass NoResponse (SNMPEngineError): """No SNMP response arrived before timeout """ passclass BadVersion (SNMPEngineError): """Unsupported SNMP version """ passclass BadCommunity (SNMPEngineError): """Bad SNMP community name """ passclass BadRequestID (SNMPEngineError): """SNMP request/response IDs mismatched """ passclass EmptyResponse (SNMPEngineError): """Empty SNMP response """ passclass BadPDUType (SNMPEngineError): """Bad SNMP PDU type """ passclass TransportError (SNMPEngineError): """Network transport error """ def __init__ (self, why): self.why = why def __str__ (self): return '%s' % self.why ## SNMP errors#class SNMPError(PySNMPError): """RFC 1157 SNMP errors """ # Taken from UCD SNMP code errors = [ '(noError) No Error', '(tooBig) Response message would have been too large.', '(noSuchName) There is no such variable name in this MIB.', '(badValue) The value given has the wrong type or length.', '(readOnly) The two parties used do not have access to use the specified SNMP PDU.', '(genError) A general failure occured.', # The rest is unlikely to ever be reported by a v.1 agent '(noAccess) Access denied.', '(wrongType) Wrong BER type', '(wrongLength) Wrong BER length.', '(wrongEncoding) Wrong BER encoding.', '(wrongValue) Wrong value.', '(noCreation) ', '(inconsistentValue) ', '(resourceUnavailable) ', '(commitFailed) ', '(undoFailed) ', '(authorizationError) ', '(notWritable) ', '(inconsistentName) ' ] def __init__ (self, status, index): self.status = status self.index = index def __str__ (self): """Return verbose error message if known """ if self.status > 0 and self.status < len(self.errors): return self.errors[self.status]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -