Getvar / setvar and exceptions

Hi Chris,

Does it make sense to have getvar and setvar raise a different exception than RuntimeError when the variable is not found, to allow specifically catching that error? (mworkscore.UnknownVariableError?)

What I’m trying to do is:

if 'variablename' in mworkscore.codec:

and now I’m doing it as

try:
    getvar('variablename')
except RuntimeError:

Which is probably a decent workaround.

Mark

Hi Mark,

I’m already planning to add a method to get the names of all variables (probably mworkscore.getcodec). Once that’s done, would a custom “UnknownVariableError” exception still be useful? My feeling is that it wouldn’t.

Chris

Sounds good - the codec solution would work for us and obviate the exception.

Mark