Skip to content

Commit

Permalink
Ticket 784: traceback (#1474)
Browse files Browse the repository at this point in the history
* 'traceback' is already formatted

* add debug / example code for full tracebacks
  • Loading branch information
meejah committed Mar 13, 2021
1 parent fa5c96f commit 7d4e812
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autobahn/wamp/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def error_message(self):

def __unicode__(self):
if self.kwargs and 'traceback' in self.kwargs:
tb = ':\n' + '\n'.join(self.kwargs.pop('traceback')) + '\n'
tb = ':\n' + self.kwargs.pop('traceback') + '\n'
self.kwargs['traceback'] = '...'
else:
tb = ''
Expand Down
4 changes: 4 additions & 0 deletions examples/twisted/wamp/component/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
@component.on_join
def join(session, details):
print("joined {}: {}".format(session, details))
# if you want full tracbacks on the client-side, you enable that
# here:
# session.traceback_app = True


@component.register(
Expand All @@ -64,6 +67,7 @@ def join(session, details):
)
@inlineCallbacks
def foo(*args, **kw):
# raise RuntimeError("bad stuff")
print("foo({}, {})".format(args, kw))
for x in range(5, 0, -1):
print(" returning in {}".format(x))
Expand Down
8 changes: 7 additions & 1 deletion examples/twisted/wamp/component/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ def main(reactor, session):
print("prefix-match 'prefix.fail.' failed as expected: {}".format(e.error))

print("calling 'example.foo'")
res = yield session.call("example.foo")
try:
res = yield session.call("example.foo")
except Exception as e:
# to see errors uncomment the "throw" in backend .. also try
# with .traceback_app enabled (in the backend)
print("Error from 'example.foo' call:")
print(e)
print("example.foo() = {}".format(res))

print("done")
Expand Down

0 comments on commit 7d4e812

Please sign in to comment.