| 103 | |
| 104 | |
| 105 | void writeQueryAroundTheError( |
| 106 | WriteBuffer & out, |
| 107 | const char * begin, |
| 108 | const char * end, |
| 109 | bool hilite, |
| 110 | const Token * positions_to_hilite, |
| 111 | size_t num_positions_to_hilite) |
| 112 | { |
| 113 | if (hilite) |
| 114 | { |
| 115 | out << ":\n\n"; |
| 116 | writeQueryWithHighlightedErrorPositions(out, begin, end, positions_to_hilite, num_positions_to_hilite); |
| 117 | out << "\n\n"; |
| 118 | } |
| 119 | else |
| 120 | { |
| 121 | if (num_positions_to_hilite) |
| 122 | { |
| 123 | const char * example_begin = positions_to_hilite[0].begin; |
| 124 | size_t total_bytes = end - example_begin; |
| 125 | size_t show_bytes = UTF8::computeBytesBeforeWidth( |
| 126 | reinterpret_cast<const UInt8 *>(example_begin), total_bytes, 0, SHOW_CHARS_ON_SYNTAX_ERROR); |
| 127 | out << ": " << std::string(example_begin, show_bytes) << (show_bytes < total_bytes ? "... " : ". "); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | |
| 133 | void writeCommonErrorMessage( |
no test coverage detected