Improve error handling
Introduce properly defined return codes and raise exceptions with descriptive error messages in the Python wrapper.
Introduce properly defined return codes and raise exceptions with descriptive error messages in the Python wrapper.