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

bug: python exception module name and class name both don't match #5452

Closed
1 task done
trim21 opened this issue Dec 25, 2024 · 0 comments · Fixed by #5453
Closed
1 task done

bug: python exception module name and class name both don't match #5452

trim21 opened this issue Dec 25, 2024 · 0 comments · Fixed by #5453
Labels
bug Something isn't working

Comments

@trim21
Copy link
Contributor

trim21 commented Dec 25, 2024

Describe the bug

op.read("non-exists-path") will throw exception like this:

Traceback (most recent call last):
  File "C:\Users\Trim21\proj\test\f.py", line 13, in <module>
    op.read("non-exists-path")
opendal.NotFoundError: NotFound (permanent) at stat, context: { service: redis, path: non-exists-path } => kv doesn't have this path

But if you actually try to catch exception opendal.NotFoundError you will encounter another error:

try:
    op.read("non-exists-path")
except opendal.NotFoundError as e:
    print(e)
Traceback (most recent call last):
  File "C:\Users\Trim21\proj\test\f.py", line 14, in <module>
    op.read("non-exists-path")
opendal.NotFoundError: NotFound (permanent) at stat, context: { service: redis, path: non-exists-path } => kv doesn't have this path

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Trim21\proj\test\f.py", line 15, in <module>
    except opendal.NotFoundError as e:
AttributeError: module 'opendal' has no attribute 'NotFoundError'

what actually work, which is not opendal nor NotFoundError, but opendal.exceptions.NotFound :

try:
    op.read("non-exists-path")
except opendal.exceptions.NotFound as e:
    print(e)

Steps to Reproduce

import opendal


op = opendal.Operator(...)    

try:
    op.read("non-exists-path")
except opendal.NotFoundError as e:
    print(e)

Expected Behavior

exception module name should match or re-export them from top level

Additional Context

No response

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.
@trim21 trim21 added the bug Something isn't working label Dec 25, 2024
@trim21 trim21 changed the title bug: python exception module name doesn't match bug: python exception module name and class name both don't match Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant