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

Iterator returned from query ignores error handling #10

Open
Raynos opened this issue Feb 15, 2020 · 4 comments
Open

Iterator returned from query ignores error handling #10

Raynos opened this issue Feb 15, 2020 · 4 comments

Comments

@Raynos
Copy link
Contributor

Raynos commented Feb 15, 2020

The iterator from query() just returns key & `value.

const iterator = table.query(`hash = N(greetings) AND begins_with(range, S(hell))`)

for await (const { key, value } of iterator) {
  console.log(key, value)
}

Do we want

for await (const { err, data: { key, value } } of iterator) {
@heapwolf
Copy link
Member

actually it throws. which is more conventional

@Raynos
Copy link
Contributor Author

Raynos commented Feb 15, 2020

Same applies to scan()

@Raynos
Copy link
Contributor Author

Raynos commented Feb 15, 2020

Throwing is fine, but then please also throw for table.get() and table.put() instead of returning { err }.

We should not mix the error handling of throw vs return { err } in the same codebase.

@heapwolf
Copy link
Member

hmm. ok yeah.. { err, data } is more correct and more useful.

for await (const { err, data: { key, value } } of iterator) {

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

2 participants