Skip to content

Commit

Permalink
feat: Add GEOARROW_RETURN_NOT_OK() macro helper (#82)
Browse files Browse the repository at this point in the history
This is pretty essential for doing any kind of readable thing with the C
library. It's a little too tempting for users of `geoarrow.h` to reach
into the (supposedly private) bundled nanoarrow for its helper...this
should really be provided given the recommend error handling approach!
  • Loading branch information
paleolimbot authored Nov 30, 2023
1 parent 7ae1089 commit 898af28
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/geoarrow/geoarrow_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ struct ArrowArrayStream {
/// \ingroup geoarrow-utility
#define GEOARROW_OK 0

#define _GEOARROW_CONCAT(x, y) x##y
#define _GEOARROW_MAKE_NAME(x, y) _GEOARROW_CONCAT(x, y)

#define _GEOARROW_RETURN_NOT_OK_IMPL(NAME, EXPR) \
do { \
const int NAME = (EXPR); \
if (NAME) return NAME; \
} while (0)

/// \brief Macro helper for error handling
/// \ingroup geoarrow-utility
#define GEOARROW_RETURN_NOT_OK(EXPR) \
_GEOARROW_RETURN_NOT_OK_IMPL(_GEOARROW_MAKE_NAME(errno_status_, __COUNTER__), EXPR)

/// \brief Represents an errno-compatible error code
/// \ingroup geoarrow-utility
typedef int GeoArrowErrorCode;
Expand Down

0 comments on commit 898af28

Please sign in to comment.