Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytrap: improved error message on bad UniRec field redefinition #234

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (even in a different NEMEA module due to global context) 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
Loading