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

Remove Result<_, InteractError> from interact signature #365

Open
bikeshedder opened this issue Nov 11, 2024 · 0 comments
Open

Remove Result<_, InteractError> from interact signature #365

bikeshedder opened this issue Nov 11, 2024 · 0 comments
Labels
A-diesel Area: Diesel / deadpool-diesel A-r2d2 Area: rd2d / deadpool-r2d2 A-sqlite Area: SQLite / deadpool-sqlite discussion enhancement New feature or request quality of life Improvements to the API resulting in a better quality of life for the users of deadpool.

Comments

@bikeshedder
Copy link
Owner

The return type of interact is questionable at best:

  • InteractError::Panic is dangerous to ignore
  • InteractError::Aborted will never be created when using the SyncWrapper interface

I'm proposing to remove this Result from the call signature

-pub async fn interact<F, R>(&self, f: F) -> Result<R, InteractError>
+pub async fn interact<F, R>(&self, f: F) -> R

What happens in the error cases?

It just panics. 💥

Why is this a good thing?

I think most users of the library will just log an error and ignore the InteractError anyways. The default behavior should be to escalate the error rather than trying to handle it "gracefully".

For those people that really know what they're doing and need to handle panics an additional interact_safe could be added which does behave exactly like before.

I'm interested to hear from users of this library if they ever had a need for handling a panic (or abortion) after an interact call.

@bikeshedder bikeshedder added enhancement New feature or request A-diesel Area: Diesel / deadpool-diesel A-sqlite Area: SQLite / deadpool-sqlite A-r2d2 Area: rd2d / deadpool-r2d2 discussion quality of life Improvements to the API resulting in a better quality of life for the users of deadpool. labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diesel Area: Diesel / deadpool-diesel A-r2d2 Area: rd2d / deadpool-r2d2 A-sqlite Area: SQLite / deadpool-sqlite discussion enhancement New feature or request quality of life Improvements to the API resulting in a better quality of life for the users of deadpool.
Projects
None yet
Development

No branches or pull requests

1 participant