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:
parent
2eb1612d46
commit
174bf146e5
|
@ -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));
|
||||
}}
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue