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

Code quality: NameOf and ValueOf should return errors #958

Closed
paralin opened this issue Jun 17, 2021 · 2 comments
Closed

Code quality: NameOf and ValueOf should return errors #958

paralin opened this issue Jun 17, 2021 · 2 comments

Comments

@paralin
Copy link
Contributor

paralin commented Jun 17, 2021

Throughout the code there are calls to ValueOf() and NameOf() on the QuadStore. The QuadStore currently returns a single value for these functions without an error, but internally the QuadStore might run into some errors when processing the value. This hack is clearly identified in the code: rather than return the error, it's just logged, i.e.:

clog.Errorf("Error in NameOf, context is nil, graph not correctly initialised")
return nil

If the QuadStore has an error while processing ValueOf or NameOf, the returned value will be nil which might lead to many types of undefined behavior - such as queries returning "nil" for one field of a Quad.

@paralin
Copy link
Contributor Author

paralin commented Jun 17, 2021

Similarly QuadDirection should return an error

@paralin
Copy link
Contributor Author

paralin commented Jun 17, 2021

I refactored the code to add error returns values to those funcs: #959

@paralin paralin closed this as completed Jun 18, 2021
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

1 participant