[Newbies] Style advice - errors; compound results

Stephen Davies stephen.l.davies at gmail.com
Sun Sep 3 16:17:02 UTC 2006


I'm looking for advice on two matters of style:

1) Errors

I'm going something that uses TCP.  What's the usual style for
handling errors?  (I mean unexpected things - like, data doesn't
arrive from then network peer as expected).  Do I raise an error using
self error:, or do I return some sort of failure code?

If I raise an error, is there a way for the caller to trap that?
This is a server, and we don't want errors popping up all of a sudden
in production.

2) Compound results

My code sends commands to the peer system, and gets back results.  The
result depends on the command, but is at least a success or failure, a
result code, and sometimes more stuff.  On top of that I also might
have the "network" success/failure.

What's the usual way to wrap all this into a result from my class?  I
am leaning to wrapping up this result info into a new object and
passing that object back.  Alternatives are to return the "main"
result, and store the other information to be fetched if needed.  Or,
just return an array or dictionary or something.

So what's the usual style - are there some classes I can look at for


More information about the Beginners mailing list