You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have two separate exception classes in errors module,
classYPYErrorCode(Enum):
INVALID_UNION_VALUE='Cannot translate union value'INVALID_ENCODE_VALUE='Cannot encode value'INVALID_HIERARCHY_PARENT='Parent is not set. \ Parent Hierarchy cannot be determined'INVALID_HIERARCHY_KEY='Key value is not set. \ Parent hierarchy cannot be constructed'INVALID_RPC='Object is not an RPC, cannot execute non-RPC object.'INVALID_MODIFY='Entity is read-only, cannot modify a read-only entity.'SERVER_REJ='Server rejected request.'SERVER_COMMIT_ERR='Server reported an error while committing change.'classYPYError(Exception):
''' Base Exception for YDK Errors '''def__init__(self, error_code=None, error_msg=None):
self.error_code=error_codeself.error_msg=error_msgdef__str__(self):
ret= []
ifself.error_codeisnotNone:
ret.append(self.error_code.value)
ifself.error_msgisnotNone:
parser=etree.XMLParser(remove_blank_text=True)
root=etree.XML(self.error_msg.xml, parser)
forrinroot.iter():
tag=r.tag[r.tag.rfind('}') +1 :]
ifr.textisnotNone:
ret.append('\t{}: {}'.format(tag, r.text.strip()))
return'\n'.join(ret)
classYPYDataValidationError(YPYError):
''' Exception for Client Side Data Validation Type Validation\n -------- Any data validation error encountered that is related to type \ validation encountered does not raise an Exception right away. To uncover as many client side issues as possible, \ an i_errors list is injected in the parent entity of any entity \ with issues. The items added to this i_errors list captures the \ object type that caused the error as well as an error message. '''pass
The YPYError class deals with server side error, and will populate error messages sent back by the device. The second one is for validation error, it use i_errors to collect as many client side issues as possible. Would it be a good practice to use a single error class, and populate error messages collected by i_errors to the enum YPYErrorCode, to reduce redundancy?
The text was updated successfully, but these errors were encountered:
Currently we have two separate exception classes in errors module,
The
YPYError
class deals with server side error, and will populate error messages sent back by the device. The second one is for validation error, it use i_errors to collect as many client side issues as possible. Would it be a good practice to use a single error class, and populate error messages collected by i_errors to the enumYPYErrorCode
, to reduce redundancy?The text was updated successfully, but these errors were encountered: