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

Fallible .load() #35

Open
Niedzwiedzw opened this issue Jun 22, 2022 · 3 comments
Open

Fallible .load() #35

Niedzwiedzw opened this issue Jun 22, 2022 · 3 comments

Comments

@Niedzwiedzw
Copy link

shouldn't .load() return Result<HashMap<_, _>> rather than just the hashmap itself? this forces me to panic on failed db request...

@cksac
Copy link
Owner

cksac commented Jun 25, 2022

is try_load suit your needs?

@gpollo
Copy link

gpollo commented Dec 3, 2023

When implementing BatchFn, the load method is not faillible. In my case, I need to do database calls that may fail. How are the errors expected to propagate? Return an empty HashMap?

I feel we probably need another type TryBatchFn with a try_load method.

@cksac
Copy link
Owner

cksac commented Dec 5, 2023

currently, in case of DB fail, return an empty map, like this test https://github.com/cksac/dataloader-rs/blob/master/tests/cached.rs#L177

However, it will only return error (key not found) without the root cause. But I think it should be sufficient for most cases.

Repository owner deleted a comment from apocanow1 Feb 20, 2024
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

No branches or pull requests

3 participants