If callee raise Exception() or an raise ApplicationError('com.crossbardemo') without args, there would be an error in protocol.py during handle the error.
The error may come with line 850 in protocol.py
errmsg = "{0}".format(err.value.args[0])
as err.value.args is an empty list
Here's the code
try:
import asyncio
except ImportError:
# Trollius >= 0.3 was renamed
import trollius as asyncio
from autobahn import wamp
from autobahn.wamp.exception import ApplicationError
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
class Component(ApplicationSession):
"""
Example WAMP application backend that raised exceptions.
"""
@asyncio.coroutine
def onJoin(self, details):
def sqrt():
# raise empty exception
raise Exception()
yield from self.register(sqrt, u'com.myapp.sqrt')
try:
yield from self.call('com.myapp.sqrt')
except:
print('exception catch')
if __name__ == '__main__':
runner = ApplicationRunner(
u"ws://f1:8080/ws",
u"crossbardemo",
debug_wamp=False, # optional; log many WAMP details
debug=False, # optional; log even more details
)
runner.run(Component)
and will come up with
C:\Anaconda3\python.exe D:/Dropbox/code/quantlib/learn/error_exception.py
Exception in callback add_callbacks.<locals>.done(<Future finis...n=Exception()>) at C:\Anaconda3\lib\site-packages\txaio\aio.py:336
handle: <Handle add_callbacks.<locals>.done(<Future finis...n=Exception()>) at C:\Anaconda3\lib\site-packages\txaio\aio.py:336>
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\txaio\aio.py", line 338, in done
res = f.result()
File "C:\Anaconda3\lib\asyncio\futures.py", line 275, in result
raise self._exception
File "C:\Anaconda3\lib\site-packages\txaio\aio.py", line 278, in as_future
res = fun(*args, **kwargs)
File "D:/Dropbox/code/quantlib/learn/error_exception.py", line 24, in sqrt
raise Exception()
Exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\asyncio\events.py", line 120, in _run
self._callback(*self._args)
File "C:\Anaconda3\lib\site-packages\txaio\aio.py", line 345, in done
errback(create_failure())
File "C:\Anaconda3\lib\site-packages\autobahn\wamp\protocol.py", line 805, in error
errmsg = "{0}".format(err.value.args[0])
IndexError: tuple index out of range
Process finished with exit code -1
If callee raise Exception() or an raise ApplicationError('com.crossbardemo') without args, there would be an error in protocol.py during handle the error.
The error may come with line 850 in protocol.py
as err.value.args is an empty list
Here's the code
and will come up with