don't return a return value that is really an error code
"Montare, Aidan A. \(Fed\) via Swig-user" <[email protected]> Fri, 5 May 2023 22:06:48 +0000
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CO6PR09MB85977A200474C0DD8E3EFF6E89729@CO6PR09MB8597.namprd09.prod.outlook.com> |
Hi! I'm wrapping a library where most of the functions follow the convention of returning an error code or 0 if no error. I've followed swig instructions to write an exception handler:
%exception {
$action
if (result != 0) {
PyErr_SetString(PyExc_RuntimeError, "an error has occurred"); // will replace with something more descriptive
SWIG_fail;
}
}
Since errors are now translated into python exceptions, I think if the function does succeed, I'd like to not return the error code 0. Many of the functions return via a parameter, and I think writing
result = foo(arg)
would be cleaner than having to write
_, result = foo(arg)
all over the place.
How can I tell swig that the error code should not be return the error code?
Best wishes,
Aidan Montare (she/her)
Time Realization and Distribution Group
Time and Frequency Division
NIST Boulder
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user