| 125 | } |
| 126 | |
| 127 | std::string Status::ToStringWithoutContextLines() const { |
| 128 | auto message = ToString(); |
| 129 | #ifdef ARROW_EXTRA_ERROR_CONTEXT |
| 130 | while (true) { |
| 131 | auto last_new_line_position = message.rfind("\n"); |
| 132 | if (last_new_line_position == std::string::npos) { |
| 133 | break; |
| 134 | } |
| 135 | // Check for the pattern ":\d+ " (colon followed by one or more digits and a space) |
| 136 | // to identify context lines in the format "filename:line expr" |
| 137 | auto colon_position = message.find(":", last_new_line_position); |
| 138 | if (colon_position == std::string::npos) { |
| 139 | break; |
| 140 | } |
| 141 | // Verify that the colon is followed by one or more digits and then a space |
| 142 | size_t pos = colon_position + 1; |
| 143 | if (pos >= message.size() || |
| 144 | !std::isdigit(static_cast<unsigned char>(message[pos]))) { |
| 145 | break; |
| 146 | } |
| 147 | // Skip all digits |
| 148 | while (pos < message.size() && |
| 149 | std::isdigit(static_cast<unsigned char>(message[pos]))) { |
| 150 | pos++; |
| 151 | } |
| 152 | // Check if followed by a space |
| 153 | if (pos >= message.size() || message[pos] != ' ') { |
| 154 | break; |
| 155 | } |
| 156 | message = message.substr(0, last_new_line_position); |
| 157 | } |
| 158 | #endif |
| 159 | return message; |
| 160 | } |
| 161 | |
| 162 | const std::string& Status::message() const { |
| 163 | static const std::string no_message = ""; |