0

I have some code where i'm trying to catch an exception and stifle it, but no matter what I do the code never prints the statement in the except block.

def check_configuration(cls, **kwargs):
    print 'product_config'
    errors = {}
    for arg in kwargs:
        if arg in cls.get_fields():
            print 'found', arg
            try:
                getattr(cls, 'clean_'+arg)
            except:
                print 'missing validation method: clean_'+attr+'()'

'missing validation method: clean_la()' never prints!

I have tried

except Exception:

except AttributeError:

they don't work either, I'm confused is there something I'm missing with exceptions?

Tim
  • 2,134
  • 3
  • 26
  • 40

1 Answers1

0

this is solved thanks to Shadow, the problem was in the except method.

attr is never defined.

print 'missing validation method: clean_'+attr+'()'
Tim
  • 2,134
  • 3
  • 26
  • 40