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

Add error returns to vertex functions #508

Merged
merged 2 commits into from
Sep 2, 2021

Conversation

isaacbrodsky
Copy link
Collaborator

These functions are not documented on the website yet, so no documentation update here.

@coveralls
Copy link

coveralls commented Aug 26, 2021

Coverage Status

Coverage decreased (-0.05%) to 98.651% when pulling 6b36d6f on isaacbrodsky:error-returns-vertex into 897f9ca on uber:master.

int cellIsPentagon = H3_EXPORT(isPentagon)(cell);
int cellNumVerts = cellIsPentagon ? NUM_PENT_VERTS : NUM_HEX_VERTS;
int res = H3_GET_RESOLUTION(cell);

// Check for invalid vertexes
if (vertexNum < 0 || vertexNum > cellNumVerts - 1) return H3_NULL;
if (vertexNum < 0 || vertexNum > cellNumVerts - 1) return E_FAILED;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an E_INVALID_INPUT error we could use here? Do we need one? It would be really useful as a developer to understand whether the input was bad or the processing failed for a different reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps E_DOMAIN, "Argument was outside of acceptable range (when a more specific error code is not available)"? This seems to most closely match what you mean by E_INVALID_INPUT. We also have E_VERTEX_INVALID if the vertex argument is invalid.

for (int i = 0; i < NUM_HEX_VERTS; i++) {
vertexes[i] = H3_EXPORT(cellToVertex)(cell, i);
if (i == 5 && isPent) {
vertexes[i] = H3_NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Better to be explicit here

@isaacbrodsky isaacbrodsky merged commit 2801fca into uber:master Sep 2, 2021
@isaacbrodsky isaacbrodsky deleted the error-returns-vertex branch September 2, 2021 19:24
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

Successfully merging this pull request may close these issues.

5 participants