Skip to content

Commit

Permalink
pytrap: improved error message on bad UniRec field redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
cejkato2 committed Oct 9, 2024
1 parent 7523514 commit 0e0a01b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pytrap/src/unirecmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,20 @@ UnirecTemplate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->urtmplt = NULL;
int ret;
if ((ret = ur_define_set_of_fields(spec)) != UR_OK) {
PyErr_SetString(TrapError, "ur_define_set_of_fields() failed.");
switch (ret) {
case UR_E_INVALID_NAME:
PyErr_SetString(TrapError, "ur_define_set_of_fields() failed due to bad name of some field in the template. The name must start with letter [a-zA-Z] and can contain only [a-zA-Z0-9_].");
break;
case UR_E_TYPE_MISMATCH:
PyErr_SetString(TrapError, "ur_define_set_of_fields() failed because some field with the existing name is being redefined with a different type, which is not allowed.");
break;
case UR_E_MEMORY:
PyErr_SetString(TrapError, "ur_define_set_of_fields() failed due to memory allocation error.");
break;
default:
// this should not happen...
PyErr_SetString(TrapError, "ur_define_set_of_fields() failed due to unkown reason.");
}
Py_DECREF(self);
return NULL;
}
Expand Down

0 comments on commit 0e0a01b

Please sign in to comment.