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

fatalError("Returned multiple objects, expected max 1") #57

Open
beefroast opened this issue Jan 12, 2020 · 3 comments
Open

fatalError("Returned multiple objects, expected max 1") #57

beefroast opened this issue Jan 12, 2020 · 3 comments

Comments

@beefroast
Copy link

What is the point of this? Why set the fetchLimit to 2 and then fatal error if two objects are returned?

@tkrajacic
Copy link

The point is to assert an assumption.

You are right, that you could just limit your query result, but that would potentially mask a serious problem. So this is a pretty good safeguard to have.

@beefroast
Copy link
Author

So why not use assert, or just throw an error so that the calling function can choose to crash if it's appropriate?

@tkrajacic
Copy link

Well, how would you recover from this error? This is really an error in the programmer's logic if this happens, so not recoverable at runtime really. You are of course free to change the logic yourself, if you think this can be handled differently. Nothing wrong with that.

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