-
Notifications
You must be signed in to change notification settings - Fork 131
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
v4 error handling #243
Labels
Comments
This was referenced May 25, 2022
Merged
One idea is to have a generic wrapper that captures and raises an error (from an H3 c library function that returns an error code), which also accepts extra arguments if that information would be useful to the user. For example, the current Cython code: cpdef int distance(H3int h1, H3int h2) except -1:
""" Compute the grid distance between two cells
"""
cdef:
int64_t distance
h3lib.H3Error err
check_cell(h1)
check_cell(h2)
err = h3lib.gridDistance(h1, h2, &distance)
if err:
# todo: do error handling later
s = 'Cells are too far apart to compute distance: {} and {}'
s = s.format(hex(h1), hex(h2))
raise H3ValueError(s)
return distance might instead look like: cpdef int distance(H3int h1, H3int h2) except -1:
""" Compute the grid distance between two cells
"""
cdef:
int64_t distance
check_for_error(
h3lib.gridDistance(h1, h2, &distance),
h1,
h2,
)
return distance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We'd like to simplify the error checking and handling in
h3-py
v4 by:For the initial v4.0 release, we might do something simple like have only a single H3 error type (as opposed to a class hierarchy of errors) that can take on various messages, and might programmatically expose the H3 core error
enum
.PRs or Issues providing examples to consider
The text was updated successfully, but these errors were encountered: