Weijun-H commented on code in PR #18511:
URL: https://github.com/apache/datafusion/pull/18511#discussion_r2506953119
##########
datafusion/common/src/error.rs:
##########
@@ -758,6 +758,116 @@ macro_rules! unwrap_or_internal_err {
};
}
+/// Assert a condition, returning `DataFusionError::Internal` on failure.
+///
+/// # Examples
+///
+/// ```text
+/// assert_or_internal_err!(predicate);
+/// assert_or_internal_err!(predicate, "human readable message");
+/// assert_or_internal_err!(predicate, format!("details: {}", value));
+/// ```
+#[macro_export]
+macro_rules! assert_or_internal_err {
+ ($cond:expr) => {
+ if !$cond {
+ return Err(DataFusionError::Internal(format!(
+ "Assertion failed: {}",
+ stringify!($cond)
+ )));
+ }
+ };
+ ($cond:expr, $msg:expr) => {
+ if !$cond {
+ return Err(DataFusionError::Internal(format!(
+ "Assertion failed: {}: {}",
+ stringify!($cond),
+ $msg
Review Comment:
Keep all three macros support the same format argument syntax
nit:
```suggestion
($cond:expr, $($arg:tt)+) => {
if !$cond {
return Err(DataFusionError::Internal(format!(
"Assertion failed: {}: {}",
stringify!($cond),
format!($($arg)+)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]