Preservation of error types

#1

I’ve got an RPC that raises a few different types of custom exceptions, and in the application calling them I need to handle the different exceptions in different ways.

However, when I raise the exceptions, the function I gave to addErrback is only receiving a Failure instance containing autobahn.wamp.exception.ApplicationError. Is there any way to preserve the type of the exception raised by RPC so that the client can handle each one properly?

0 Likes

#2

Hi Michael,

    > I've got an RPC that raises a few different types of custom exceptions, and
    > in the application calling them I need to handle the different exceptions
    > in different ways.

    > However, when I raise the exceptions, the function I gave to addErrback is
    > only receiving a Failure instance containing
    > autobahn.wamp.exception.ApplicationError. Is there any way to preserve the
    > type of the exception raised by RPC so that the client can handle each one
    > properly?

you mean something like this ?
https://github.com/crossbario/autobahn-python/tree/master/examples/asyncio/wamp/rpc/errors

0 Likes

#3

Yes, thanks!
It didn’t preserve the attributes that one of my custom exceptions had, but I was able to work around that by raising ApplicationError directly and sending those attributes as keyword arguments.

···

On Friday, June 23, 2017 at 4:33:24 PM UTC-4, Alberto Berti wrote:

Hi Michael,

> I've got an RPC that raises a few different types of custom exceptions, and
> in the application calling them I need to handle the different exceptions
> in different ways.



> However, when I raise the exceptions, the function I gave to addErrback is
> only receiving a Failure instance containing
> autobahn.wamp.exception.ApplicationError. Is there any way to preserve the
> type of the exception raised by RPC so that the client can handle each one
> properly?

you mean something like this ?

https://github.com/crossbario/autobahn-python/tree/master/examples/asyncio/wamp/rpc/errors

0 Likes