Skip to content

Proper Python exceptions instead of error codes? #4

@aldanor

Description

@aldanor

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions