Skip to content

Commit

Permalink
ARROW-4252: [C++] Fix missing Status code and newline
Browse files Browse the repository at this point in the history
Previous refactor of status message removed the stringification of the
failing expression.

Author: François Saint-Jacques <[email protected]>

Closes apache#3420 from fsaintjacques/ARROW-4252-status-error-message and squashes the following commits:

2b8d46c <François Saint-Jacques> ARROW-4252:  Fix missing Status missing code and newline
  • Loading branch information
fsaintjacques authored and wesm committed Jan 20, 2019
1 parent 5504263 commit 9855e94
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions cpp/src/arrow/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,35 @@
#ifdef ARROW_EXTRA_ERROR_CONTEXT

/// \brief Return with given status if condition is met.
#define ARROW_RETURN_IF(condition, status) \
do { \
if (ARROW_PREDICT_FALSE(condition)) { \
::arrow::Status _s = (status); \
std::stringstream ss; \
ss << __FILE__ << ":" << __LINE__ << " : " << _s.message(); \
return ::arrow::Status(_s.code(), ss.str()); \
} \
#define ARROW_RETURN_IF_(condition, status, expr) \
do { \
if (ARROW_PREDICT_FALSE(condition)) { \
::arrow::Status _s = (status); \
std::stringstream ss; \
ss << _s.message() << "\n" << __FILE__ << ":" << __LINE__ << " code: " << expr; \
return ::arrow::Status(_s.code(), ss.str()); \
} \
} while (0)

#else

#define ARROW_RETURN_IF(condition, status) \
do { \
if (ARROW_PREDICT_FALSE(condition)) { \
return (status); \
} \
#define ARROW_RETURN_IF_(condition, status, _) \
do { \
if (ARROW_PREDICT_FALSE(condition)) { \
return (status); \
} \
} while (0)

#endif // ARROW_EXTRA_ERROR_CONTEXT

#define ARROW_RETURN_IF(condition, status) \
ARROW_RETURN_IF_(condition, status, ARROW_STRINGIFY(status))

/// \brief Propagate any non-successful Status to the caller
#define ARROW_RETURN_NOT_OK(status) \
do { \
::arrow::Status __s = (status); \
ARROW_RETURN_IF(!__s.ok(), __s); \
\
#define ARROW_RETURN_NOT_OK(status) \
do { \
::arrow::Status __s = (status); \
ARROW_RETURN_IF_(!__s.ok(), __s, ARROW_STRINGIFY(status)); \
} while (false)

#define RETURN_NOT_OK_ELSE(s, else_) \
Expand Down

0 comments on commit 9855e94

Please sign in to comment.