Skip to content

Logs should not print traceback for expected failures

Right now, we're raising a SRPRegistrationError exception if the provider returns an error code (username already taken, invalid code). This exception bubbles up, and at some point (?) is trapped (probably around the dispatcher) and returned to the callee (the cli in this case).

However, we're also logging the backtrace in the logs.

This results in a confusing log, because it prints the bt for "expected" errors.

We need a way to pass the exceptions around, but NOT print them when they are expected.

 12 2016-10-03 17:32:27-0400 [-] Oops! Errors during signup: '{"invite_code": ["This code has already been used"]}'
 13 2016-10-03 17:32:27-0400 [HTTP11ClientProtocol (TLSMemoryBIOProtocol),client] Unhandled Error
 14         Traceback (most recent call last):
 15           File "/home/kali/Virtualenvs/bitmask1/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 393, in callback
 16             self._startRunCallbacks(result)
 17           File "/home/kali/Virtualenvs/bitmask1/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
 18             self._runCallbacks()
 19           File "/home/kali/Virtualenvs/bitmask1/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 587, in _runCallbacks
 20             current.result = callback(current.result, *args, **kw)
 21           File "/home/kali/Virtualenvs/bitmask1/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1241, in gotResult
 22             _inlineCallbacks(r, g, deferred)
 23         ---  ---
 24           File "/home/kali/Virtualenvs/bitmask1/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1185, in _inlineCallbacks
 25             result = g.send(result)
 26           File "/home/kali/leap/bitmask-dev/src/leap/bitmask/bonafide/session.py", line 175, in signup
 27             registered_user = self._srp_signup.process_signup(signup)
 28           File "/home/kali/leap/bitmask-dev/src/leap/bitmask/bonafide/_srp.py", line 133, in process_signup
 29             raise SRPRegistrationError(msg)
 30         leap.bitmask.bonafide._srp.SRPRegistrationError: username This code has already been used

(from redmine: created on 2016-10-04)