Python-rrdtool try except rrdtool.error module object has no attribute error

I have this code that gives this error on Linux and will be grateful if you can help

import rrdtool

try:      
      ret_asd = rrdtool.update(myfile.rrd,'N:%s:%s' %(metric1, metric2));    
except rrdtool.error, e:
      print e  

When i run the above i get the below error

except rrdtool.error, e:
AttributeError: 'module' object has no attribute 'error'

The code is intended to skip this error while updating the rrd file

illegal attempt to update using time 1363358441 when last update time is 1363358441 (minimum one second step)

Appreciate if you can help me get a solution for this

Thanks

abc.xyz in python means you're looking for an attribute (object, function, variable...) xyz inside the object abc . In your case, do you know if attribute rrdtool.error exists? Even if it does it should be a valid exception class (meaning, it should be derived from Exception class)

If you don't know or don't care what exception to catch exactly, you can always use the generic except block

import sys
import rrdtool

try:
  blah_blah
except:
    print "Exception occurred:", sys.exec_info()[0]
    raise # or do something else