Add new known errors to the error list

This commit is contained in:
Lonami Exo
2020-12-04 20:42:44 +01:00
parent 12380207ba
commit 0b0a1dc6a1
3 changed files with 13 additions and 1 deletions

View File

@@ -27,6 +27,12 @@ def _get_class_name(error_code):
abs(error_code), 'RPCError' + str(error_code).replace('-', 'Neg')
)
if error_code.startswith('2'):
error_code = re.sub(r'2', 'TWO_', error_code, count=1)
if re.match(r'\d+', error_code):
raise RuntimeError('error code starting with a digit cannot have valid Python name: {}'.format(error_code))
return snake_to_camel_case(
error_code.replace('FIRSTNAME', 'FIRST_NAME')\
.replace('SLOWMODE', 'SLOW_MODE').lower(), suffix='Error')