txamqp raise error in txthrift

Asked by DarkAnthey


How can I raise error in server with txthrift.
I have thrift shema.

exception InvalidOperation {
  1: string what,
  2: string why

And some function to raise exception for example:
if time > 60:
    raise InvalidOperation(what='Error', why='Time Error')
    return defer.fail(InvalidOperation(what='Error', why='Time Error'))
    return InvalidOperation(what='Error', why='Time Error')

But none of them is not working as expected. The server has not transferred any exception to client.

Question information

English Edit question
txAMQP Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Terry Jones (terrycojones) said :


Did you list the exception in the "throws" section of the service's Thrift definition? Just raising the exception should be enough if so.

BTW, Esteve Fernandez (the author of txAMQP) is on holidays until the end of August. I can try to help you in the meantime, but we may end up having to wait for him.


Revision history for this message
Matteo Brancaleoni (mbrancaleoni) said :

I do in this way (example code, not really working)

class MyHandler(object)

        def _worker(self):
               res = yield do_some_other_work_which_returns_a_deferred
           except Exception, e:
              raise Exception("cannot do anything")


        def thrift_method(self):
                return self._worker()
            except Exception, e:
                return defer.fail(InvalidOperation(what=logid, why=e.message))

hope that can help. remind to add throws(1: InvalidOperation, ouch) to your service definition....

Can you help with this problem?

Provide an answer of your own, or ask DarkAnthey for more information if necessary.

To post a message you must log in.