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
I'm just suggesting some custom exception classes as opposed to raising a generic RuntimeError.
This is how I currently am parsing the errors
def _parseError(e):
if type(e.args) is type(()) and len(e.args) >= 2:
if type(e.args[0]) is type(1):
return e.args[0], e.args[1]
msg = '%s' % e
err = 0
a = msg.find('[WinError')
if a > -1:
b = msg.find(']', a)
err = int(msg[a+10:b])
elif msg.find('127.0.0.1:') > -1:
a = msg.find('127.0.0.1:')
if a > -1:
msg = msg[a:a+15]
err = eErrors.ADB_CLIENT_LEFT
else:
err = eErrors.ADB_CLIENT_UNKNOWN
if err == eErrors.ADB_SERVER_UNAVAILABLE:
msg = 'ADB server not found'
return err, msg
When a RunTimeError is raised (Example: ADB server not available) you just get a text string in e.arg
When a ConnectionResetError is raised e.arg[0] has the error code as an int plus you can get a text string message.
The second approach makes writing error handlers much cleaner and easier compared to parsing strings.
Thanks
The text was updated successfully, but these errors were encountered: