Skip to content

refactor(binding/python): Add multiple custom exception for each of error code in Rust Core #3492

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

Merged
merged 7 commits into from
Nov 7, 2023

Conversation

Zheaoli
Copy link
Member

@Zheaoli Zheaoli commented Nov 6, 2023

Signed-off-by: Manjusaka [email protected]

@Zheaoli Zheaoli requested a review from messense as a code owner November 6, 2023 13:01
@Zheaoli Zheaoli force-pushed the manjusaka/polish-exception branch from 5242d1c to d95d518 Compare November 6, 2023 13:01
@Zheaoli Zheaoli changed the title reactor(binding/python): Add multiple custom exception for each of error code in Rust Core refactor(binding/python): Add multiple custom exception for each of error code in Rust Core Nov 6, 2023
@github-actions github-actions bot added the releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor" label Nov 6, 2023
@Zheaoli Zheaoli marked this pull request as draft November 6, 2023 13:10
Signed-off-by: Manjusaka <[email protected]>
Signed-off-by: Manjusaka <[email protected]>
@Zheaoli Zheaoli marked this pull request as ready for review November 6, 2023 16:36
Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM, @messense would you like to take another review?

Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should still be a catch-all opendal Exception just like the original Error type, other exceptions should subclass from it, forming an exception hierarchy.

See also PyO3/pyo3#3452

@Xuanwo
Copy link
Member

Xuanwo commented Nov 7, 2023

I think there should still be a catch-all opendal Exception just like the original Error type, other exceptions should subclass from it, forming an exception hierarchy.

So we will have opendal.exceptions.Error and all other exceptions are subclasses of it?

@messense
Copy link
Member

messense commented Nov 7, 2023

So we will have opendal.exceptions.Error and all other exceptions are subclasses of it?

Exactly, to catch any opendal exception, user should not need to catch Exception because that would also catch non-opendal exceptions.

A good exception hierarchy example is https://github.com/psf/requests/blob/main/src/requests/exceptions.py

@Zheaoli
Copy link
Member Author

Zheaoli commented Nov 7, 2023

So we will have opendal.exceptions.Error and all other exceptions are subclasses of it?

Exactly, to catch any opendal exception, user should not need to catch Exception because that would also catch non-opendal exceptions.

A good exception hierarchy example is https://github.com/psf/requests/blob/main/src/requests/exceptions.py

SGTM

Signed-off-by: Manjusaka <[email protected]>
@Zheaoli Zheaoli requested a review from messense November 7, 2023 04:43
Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a test case to ensure that catching any opendal exception using Error works?

Signed-off-by: Manjusaka <[email protected]>
This reverts commit 1d7d5a7.
Signed-off-by: Manjusaka <[email protected]>
@Xuanwo Xuanwo merged commit 87a7ac1 into main Nov 7, 2023
@Xuanwo Xuanwo deleted the manjusaka/polish-exception branch November 7, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants