hi
please use the mailing list to ask questions:
https://groups.google.com/forum/#!forum/rpyc
you will need to get hold of the remote exception class.
the easiest solution would be to have a local copy of the module defining
the exception (including it's packages).
if that's not possible, there are some options you can use:
1) catch rpyc.core.vinegar.GenericException, which is the base class of all
generated exceptions
2) look up your exception in rpyc.core.vinegar._generic_exceptions_cache by
name
3) put an exception into rpyc.core.vinegar._generic_exceptions_cache, e.g.
class MyServerException(Exception):
pass
rpyc.core.vinegar._generic_exceptions_cache["the.server.module.MyServerException"]
= MyServerException
i think (3) is best. you can also define a class decorator to hide the
gruesome details:
def vinegarify(remote_name):
def deco(cls):
rpyc.core.vinegar._generic_exceptions_cache[remote_name] = cls
return cls
return deco
@vinegarify
class MyServerException(Exception):
pass
it's quite a corner case, you usually don't expect to catch remote
exceptions that are not known on the local side...
but it's doable, as shown above.
note that i haven't tested the code, but it should work. if not, try to
tweak with it a little.
hope this helps,
-tomer
-----------------------------------------------------------------
*Tomer Filiba*
tomerfiliba.com <http://www.facebook.com/tomerfiliba>
<http://il.linkedin.com/in/tomerfiliba>
On Sun, Mar 18, 2012 at 19:11, Thibaut DIRLIK <[email protected]>wrote:
> Hi,
>
> I started to use RPyC for a projet (a 3-tier application framework, with
> client<->server communicating usiing RPyC).
>
> This a is a very good tool, because thanks to bidirictionnal RPC, I can't
> for example launch a command from the client to
> the server and then open a confirmation window on the client, wait for the
> user to answer and continue.
>
> This is just amazing :-)
>
> Anyway, I would like to raise exceptions (custom exceptions, based on
> builtin Exception) on server side and catch it on client side.
>
> Exemple:
>
> class MyServerException(Exception):
> pass
>
> server :
> raise MyServerException('ERROR')
>
> client:
> try:
> xxx
> except <What to put here to get MyServerException>:
> pass
>
> Thanks for your help, and continue working on RPyC, it's an amazing tool !
>