Better messages and return codes in applications

Use stderr and return codes >0 when it makes sense.
Loose return code conventions:
* 1 for generic errors
* 2 for user input errors
* 3 for remote errors (not found, etc.)
* 4 for not implemented
This commit is contained in:
Laurent Bachelier 2011-05-03 01:02:00 +02:00
commit 8075d538f0
18 changed files with 168 additions and 149 deletions

View file

@ -342,8 +342,8 @@ class Boobmsg(ReplApplication):
Read a message
"""
if len(arg) == 0:
print 'Please give a message ID.'
return
print >>sys.stderr, 'Please give a message ID.'
return 2
try:
message = self.messages[int(arg) - 1]
@ -355,6 +355,8 @@ class Boobmsg(ReplApplication):
return
if not self.interactive:
print 'Oops, you need to be in interactive mode to read messages'
print >>sys.stderr, 'Oops, you need to be in interactive mode to read messages'
return 1
else:
print 'Message not found'
print >>sys.stderr, 'Message not found'
return 3