romainfrancois commented on pull request #11534: URL: https://github.com/apache/arrow/pull/11534#issuecomment-964978449
It's tricky because when `ARROW_EXTRA_ERROR_CONTEXT` is defined, these lines are automatically added by each `RETURN_NOT_OK` and there's no runtime opt-out. https://github.com/apache/arrow/blob/1ddd644210888a0996754d5f5d517699dcf6c446/cpp/src/arrow/status.h#L28 The extra context info is merely added to the status message: https://github.com/apache/arrow/blob/1ddd644210888a0996754d5f5d517699dcf6c446/cpp/src/arrow/status.cc#L135 I can offer this to remove the extra context information, this might be enough here: ```r err_remove_context <- function(cnd) { msg <- strsplit(cnd$message, "\n")[[1]] msg <- msg[!grepl("^.*:\\d+ ", msg)] cnd$message <- paste(msg, collapse = "\n") rlang::cnd_signal(cnd) } err_snap <- function(expr){ (expect_error( withCallingHandlers(expr, simpleError = err_remove_context) )) } ``` But it feels fragile. Perhaps one thing that we could do to improve on this would be to improve `StopIfNotOk()` so that it would identify the error as something that originated from an arrow status: ```cpp static inline void StopIfNotOk(const Status& status) { if (!status.ok()) { // ARROW-13039: be careful not to interpret our error message as a %-format string std::string s = status.ToString(); cpp11::stop("%s", s.c_str()); } } ``` at the moment, it just calls `cpp11::stop()` https://github.com/r-lib/cpp11/blob/d89706a83324a57c2ff25fb46bbe9cc3770caee0/inst/include/cpp11/protect.hpp#L254 which in turns calls `Rf_errorcall()`. This does not give a mechanism to add a class to the error message. -- 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]
