@@ -88,10 +88,16 @@ class MakeErrorStream {
8888 return *this ;
8989 }
9090
91- // Adds RET_CHECK failure text to error message.
92- MakeErrorStreamWithOutput& add_ret_check_failure (const char * condition) {
93- return *this << " RET_CHECK failure (" << impl_->file_ << " :" << impl_->line_
94- << " ) " << condition << " " ;
91+ // Adds RET_CHECK_OK failure text to error message.
92+ MakeErrorStreamWithOutput& add_ret_check_ok_failure (const char * condition) {
93+ return *this << " RET_CHECK_OK failure (" << impl_->file_ << " :"
94+ << impl_->line_ << " ) " << condition << " " ;
95+ }
96+
97+ // Adds RET_CHECK_TRUE failure text to error message.
98+ MakeErrorStreamWithOutput& add_ret_check_true_failure () {
99+ return *this << " RET_CHECK_TRUE failure (" << impl_->file_ << " :"
100+ << impl_->line_ << " ) " ;
95101 }
96102
97103 private:
@@ -175,15 +181,23 @@ absl::Status ToAbslStatus(const tensorflow::Status& status);
175181// Converts from absl::Status to grpc::Status.
176182grpc::Status ToGrpcStatus (const absl::Status& status);
177183
178- // Checks if given condition returns Ok status, if not, returns an error status
184+ // Checks if given condition returns Ok status. If not, returns an error status
179185// and stack trace.
180- #undef RET_CHECK
181- #define RET_CHECK (condition ) \
186+ #undef RET_CHECK_OK
187+ #define RET_CHECK_OK (condition ) \
182188 while (TF_PREDICT_FALSE(!(condition.ok()))) \
183189 return carls::internal::MakeErrorStream(__FILE__, __LINE__, \
184190 absl::StatusCode::kInternal ) \
185191 .with_log_stack_trace() \
186- .add_ret_check_failure(#condition)
192+ .add_ret_check_ok_failure(#condition)
193+
194+ // Checks if given condition returns true. If not, returns the stack trace.
195+ #define RET_CHECK_TRUE (condition ) \
196+ while (TF_PREDICT_FALSE(!(condition))) \
197+ return carls::internal::MakeErrorStream(__FILE__, __LINE__, \
198+ absl::StatusCode::kInternal ) \
199+ .with_log_stack_trace() \
200+ .add_ret_check_true_failure()
187201
188202} // namespace carls
189203
0 commit comments