viirya commented on code in PR #7115:
URL: https://github.com/apache/arrow-datafusion/pull/7115#discussion_r1281143181
##########
datafusion/common/src/error.rs:
##########
@@ -411,6 +399,56 @@ impl DataFusionError {
}
}
+/// Unwrap an `Option` if possible. Otherwise return an
`DataFusionError::Internal`.
+/// In normal usage of DataFusion the unwrap should always succeed.
+///
+/// Example: `let values = unwrap_or_internal_err!(values)`
+#[macro_export]
+macro_rules! unwrap_or_internal_err {
+ ($Value: ident) => {
+ $Value.ok_or_else(|| {
+ DataFusionError::Internal(format!(
+ "{} should not be None",
+ stringify!($Value)
+ ))
+ })?
+ };
+}
+
+#[macro_export]
+macro_rules! with_dollar_sign {
+ ($($body:tt)*) => {
+ macro_rules! __with_dollar_sign { $($body)* }
+ __with_dollar_sign!($);
+ }
+}
Review Comment:
Hmm, does it define a macro `__with_dollar_sign` every time
`with_dollar_sign` is called? If we call `make_error` multiple times, does it
conflict?
--
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]