"Thomas Jakobsen" <[EMAIL PROTECTED]> writes:

Hi Thomas,

This is just some scattered thoughts...

> [...] logging and for sending to the VIFF developers for debugging.

For logging information as we go along I suggest we use one of the
standard Python frameworks, see:

  http://tracker.viff.dk/issue5

> Another question is how this could be implemented in VIFF. As far as I
> know, exceptions in Python take an array of arguments, so we could
> define the first to be the user message and the second to be a
> detailed msg.

Exceptions are just classes which normally derive from the Exception
class (I'm not even sure this is a hard requirement). But they can take
any arguments you like. Old-style syntax was

  raise ValueError "bad idea"

but that has been deprecated and replaced by

  raise ValueError("bad idea")

There are some info about the standard exceptions here:

  http://docs.python.org/lib/module-exceptions.html

> But how do we then distinguish exceptions with nice user messages from
> other exceptions? One way could be to use a custom exception class
> that has a userMsg and a detailedMsg field:
>
>    raise NiceCustomException(<user message>, <detailed message>)

The standard class Exception (or BaseException in Python 2.5) has an
args attribute for the constructor arguments, and a message attribute
for a single message.

> or simply
>
>    raise NiceCustomException(<message>)
>
> if there is no need to distinguish. Further, if we let the
> NiceCustomException have room for an inner exception, we have the
> opportunity to intercept an exception from somewhere else and equip it
> with an appropriate user message, e.g.:
>
>   try:
>      externalLib.doComplicatedDecryptStuff()
>   except BadPaddingException, inst:
>      raise NiceCustomException("Could'nt decrypt, wrong password?", 
> inner=inst)
>
> Again, this will allow the programmer of a VIFF-based application to
> expose the user to a short and descriptive explanation while keeping
> access to all detailed info about the problem that has occured. When
> we use the custom exception solution, he will also be able to
> distinguish between an exception with a nice user message and, say,
> some unpredictable and hairy RuntimeException where the user is most
> happy knowing only that "Some exception occured".

We could do something like that. And then we will also have to take into
account the way exceptions are used with Twisted. I think this picture
explains it quite well:

  http://twistedmatrix.com/projects/core/documentation/howto/defer.html#auto2

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.

Attachment: pgpkoRtAwESWX.pgp
Description: PGP signature

_______________________________________________
viff-devel mailing list (http://viff.dk/)
viff-devel@viff.dk
http://lists.viff.dk/listinfo.cgi/viff-devel-viff.dk

Reply via email to