I want to catch a specific ValueError
, not just any ValueError
.
I tried something like this:
try: maquina['WPF'] = macdat(ibus, id, 'WPF')
except: ValueError, 'For STRING = ’WPF’, this machine is not a wind machine.':
pass
But it raises a SyntaxError: can't assign to literal.
Then I tried:
try: maquina['WPF'] = macdat(ibus, id, 'WPF')
except ValueError, e:
if e != 'For STRING = ’WPF’, this machine is not a wind machine.':
raise ValueError, e
But it raises the exception, even if it is the one I want to avoid.