I'm new to Python and I am writing a simple FTP client.  I am having trouble handling errors like connection refused, invalid username or password, and the like.  I can use a try exception block like this

try:
  ftp=FTP('some_server')
  ftp.login()
  # more lines
except:
  print "An error has occured.\n"

This works fine to supress the errors, but I would like to be able to narrow the errors down so that I can print 'invalid username or password' or 'connection refused' rather than simply 'An error has occured'.  How would I go about narrowing down which errors occur?

Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to