[Twisted-Python] some errors twisted does not handle gracefully

Cory Dodt corydodt at yahoo.com
Tue Feb 5 04:21:08 EST 2002


I'm trying to make a catalog of these.  Twisted needs to have
better-defined exceptions for certain conditions instead of relying on
Python to report the error via tracebacks.  More specific errors would
allow the developer to more quickly track down the problem. 
Furthermore,
programmatic handling of exceptions in the client should be feasible. 
Handling a TypeError that could be a bug in your code the same as an
unauthorized-client-action style error means you have to accept that
bugs
in your code will be masked if you catch these.

Here's the list:


1) cause: Didn't set 'application' in a config.tac.

results in this message in the log:

"05/02/2002 00:50 [-] Python file
'/home/cdodt/TwistedPlugins/dataconda/config.tac' did not produce an
application."

This isn't gross, but there's no reason not to give more information
here.
 Even though I knew about this requirement, I had forgotten about it and
renamed a variable, resulting in this situation.  The log message wasn't
helpful in reminding me.  It should be just a little more specific:
"config.tac must set a variable named 'application'.  No application was
produced."


2) cause: Trying to log in as an Identity that never had a password set

Traceback! exceptions.TypeError, argument must be string or read-only
buffer, not None
/usr/lib/python2.1/site-packages/twisted/spread/pb.py:759:_recvMessage
/usr/lib/python2.1/site-packages/twisted/spread/flavors.py:155:remoteMessageReceived
/usr/lib/python2.1/site-packages/twisted/spread/pb.py:958:remote_respond
/usr/lib/python2.1/site-packages/twisted/cred/identity.py:123:verifyPassword

This one is pretty ugly.  It's valid to have an Identity with no password.
(If it isn't, then you shouldn't be able to create one.)  In my case,
it just means that user can't log in.  If we must throw an exception
here,
throw "IdentityWithNullPasswordError" or something like that, and better
yet, name the identity with the problem.


3) cause: calling a method with the wrong name on a RemoteReferenced
object (Perspective, Referenceable, etc.)

Traceback! exceptions.AttributeError, LobbyUser instance has no
attribute 'perspective_xxx'
/usr/lib/python2.1/site-packages/twisted/spread/pb.py:759:_recvMessage
/usr/lib/python2.1/site-packages/twisted/spread/pb.py:194:perspectiveMessageReceived

Well ok, duh, at least this one I can figure out.  But it should still
be something more specific: 'RemoteMethodNotImplementedError' for
example.

I will send more as I find them.

Thanks!
C


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com




More information about the Twisted-Python mailing list