topless topless - 1 year ago 88
Python Question

How can I handle a boto exception in python?

How can I wrap a

call in python so I can handle possible exceptions?

Answer Source

The first question is what exceptions is this call likely to generate? You do not want to make a blanket exception handler in any language. You should first take a look at the Boto documentation to see if it documents the exceptions you might see from a given call, but if not I would first try:

  uri = boto.storage_uri()
except Exception as e:

Or log the exception (with the logging package exception method), but either way you want to take note of what types of exceptions you see while you're testing and whether you should handle any of them specially. You also may want to review the Python Tutorial section on Exceptions and Errors.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download