Why won't this `try` statement catch this` CannotSendRequest` error? python
try:
serial_tx = bcl.sendrawtransaction(tx)
except:
raise
''other stuff''
tx
in brackets is an unprocessed transaction that needs to be sent to the network. This was the result -
Internal Server Error: /blockscript/0d82f8c8f85ed2b8226dd98ad967c81b00000000000074cfc81b5e3cfdef19975408ef2c2d9976160c69dd2057505d5a/
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/media/derrend/data/Development/projectone/pro1/views.py", line 1012, in blockscript
process_rec(tx, L_dct=L_dct, W_dct=W_dct)
File "/media/derrend/data/Development/projectone/pro1/views.py", line 494, in process_rec
serial_tx = bcl.sendrawtransaction(tx)
File "/usr/local/lib/python2.7/dist-packages/python_bitcoinlib-0.2_SNAPSHOT-py2.7.egg/bitcoin/rpc.py", line 403, in sendrawtransaction
r = self._call('sendrawtransaction', hextx)
File "/usr/local/lib/python2.7/dist-packages/python_bitcoinlib-0.2_SNAPSHOT-py2.7.egg/bitcoin/rpc.py", line 163, in _call
'Content-type': 'application/json'})
File "/usr/lib/python2.7/httplib.py", line 973, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1001, in _send_request
self.putrequest(method, url, **skips)
File "/usr/lib/python2.7/httplib.py", line 871, in putrequest
raise CannotSendRequest()
CannotSendRequest
Thank you in advance:)
EDIT:
I originally shortened the error for the sake of the forum, but now I have updated it with full error output. Thanks again:)
EDIT2:
I just saw that there is a boost in the try statement that I added to the main post above. Usually the error reported by this is that "boost can't be anything" or something like that, but that's not what I'm seeing this time around. I have mentioned though in case he invents somehow.
source to share
raise
catches the caught exception on its own while keeping the stack trace. If you don't want the exception to propagate, remove raise
.
What you describe in your question only occurs when using bare raise
with no exception handling and only in Python 2:
Usually the error reported by this is that "boost can't be anything" or something like that
exact error:
TypeError: Exceptions must be old-style classes or derived from BaseException, not NoneTyp e
... In Python 3, its more specific:
RuntimeError: No active exception to reraise
... but again, this should never be applied in a block except
.
source to share