bindings: Better error handling in enumeration get() function.

Prior to this patch a call to get() with an invalid enumeration value
would raise an exception that would, for example, terminate the python
interpreter, whereas now the exception is handled and translated into a
proper python exception.
This commit is contained in:
Jens Steinhauser 2014-10-07 14:01:34 +02:00 committed by Bert Vermeulen
parent 2eb1612d46
commit 174bf146e5
1 changed files with 3 additions and 0 deletions

View File

@ -95,6 +95,9 @@ code_template = """
const {classname} *{classname}::get(int id)
{{
if (_values.find(static_cast<{enumname}>(id)) == _values.end())
throw Error(SR_ERR_ARG);
return {classname}::_values.at(static_cast<{enumname}>(id));
}}
"""