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

Proper Python exceptions instead of error codes? #4

Open
aldanor opened this issue Jun 10, 2019 · 0 comments
Open

Proper Python exceptions instead of error codes? #4

aldanor opened this issue Jun 10, 2019 · 0 comments

Comments

@aldanor
Copy link

aldanor commented Jun 10, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant