[Twisted-Python] Transforming Exception -> pb.Error in a remote_foo method
![](https://secure.gravatar.com/avatar/42148ea9c50179d54c77987a998af7a0.jpg?s=120&d=mm&r=g)
Hi, In the Twisted docs it is claimed that in order to propagate exceptions over PB: "The only special thing you do is to define your Exception subclass by deriving it from pb.Error. " This seems simple enough, but I am using PB to adapt a general service that doesn't use pb.Errors (as the service is also adapted to other protocols). How can one transform a regular Exception to a pb.Error? The following does not work: def remote_foo(self, f): d = self.service.foo(f) def raiser(): raise pb.Error('I pbfailed') d.addErrback(lambda reason: raiser()) # reason is an Exception, not a pb.Error! return d In this case, the server still complains about an unhandled exception. Any thoughts about how to do this? Thanks Brian
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Wed, 20 Dec 2006 10:17:04 -0700, Brian Granger <ellisonbg.net@gmail.com> wrote:
Hi,
In the Twisted docs it is claimed that in order to propagate exceptions over PB:
"The only special thing you do is to define your Exception subclass by deriving it from pb.Error. "
This seems simple enough, but I am using PB to adapt a general service that doesn't use pb.Errors (as the service is also adapted to other protocols). How can one transform a regular Exception to a pb.Error? The following does not work:
This is a bug in PB's handling of Deferreds which fail with an Error. They are not handled in the same way as Errors which are raised synchronously by the method to which the PB message is dispatched. Could you file a ticket in the tracker? Jean-Paul
participants (2)
-
Brian Granger
-
Jean-Paul Calderone