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

How do I catch (nimpy.KeyError) in Python? #207

Open
yuyamashiro opened this issue May 20, 2021 · 4 comments · May be fixed by #300
Open

How do I catch (nimpy.KeyError) in Python? #207

yuyamashiro opened this issue May 20, 2021 · 4 comments · May be fixed by #300

Comments

@yuyamashiro
Copy link

I want to except nimpy.KeyError.
However I can't do it.

Example:

try:
        # Some code: call Nim by nimpy
    except KeyError as e:
        # I  can't catch nimpy.KeyError
        print("key error")
        print(e, type(e))
    except Exception as e:
        print("Unknown")
        print(e, type(e))
        raise e

Output

Unknown
Unexpected error encountered: key not found: city <class 'nimpy.KeyError'>
nimpy.KeyError: ...

How do I catch nimpy.KeyError?

@qb-0
Copy link

qb-0 commented Jul 23, 2022

I'm also interested how nimpy exceptions can be catched. Or how Python Exceptions could be raised from nim.

@PaarthShah
Copy link

This is a very old issue, but it's affecting me too, and I think I have a way to fix nimpy to raise native python exceptions when possible.

@PaarthShah
Copy link

Made a PR for this: #300

@juzt3
Copy link

juzt3 commented Dec 20, 2024

we need this

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

Successfully merging a pull request may close this issue.

4 participants