mkl-service
mkl-service copied to clipboard
Proper Python exceptions instead of error codes?
Currently, any exception raised will be ignored and it will print "exception is ignored" to stderr. Then, the user has to manage all those error codes manually (which requires reading Cython source code which may be a bit too much for an average user).
Maybe throw proper Python exceptions instead? That would arguably be a much more Pythonic way of doing that:
https://cython.readthedocs.io/en/latest/src/userguide/language_basics.html#error-return-values
So instead of stuff like
return_code = mkl.set_foo(...)
if return_code != 'success':
if return_code == 'err_invalid_input':
raise RuntimeError('invalid input in mkl')
you could do just
mkl.set_foo(...)
which would throw an MKLError('invalid input')
if it fails, so you could catch it later.