MCPcopy Create free account
hub / github.com/ByConity/ByConity / writeCommonErrorMessage

Function writeCommonErrorMessage

src/Parsers/parseQuery.cpp:150–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150void writeCommonErrorMessage(
151 WriteBuffer & out,
152 const char * begin,
153 const char * end,
154 Token last_token,
155 const std::string & query_description)
156{
157 out << "Syntax error";
158
159 if (!query_description.empty())
160 out << " (" << query_description << ")";
161
162 out << ": failed at position " << (last_token.begin - begin + 1);
163
164 if (last_token.type == TokenType::EndOfStream || last_token.type == TokenType::Semicolon)
165 {
166 out << " (end of query)";
167 }
168 else
169 {
170 out << " ('" << std::string(last_token.begin, last_token.end - last_token.begin) << "')";
171 }
172
173 /// If query is multiline.
174 const char * nl = find_first_symbols<'\n'>(begin, end);
175 if (nl + 1 < end)
176 {
177 size_t line = 0;
178 size_t col = 0;
179 std::tie(line, col) = getLineAndCol(begin, last_token.begin);
180
181 out << " (line " << line << ", col " << col << ")";
182 }
183}
184
185
186std::string getSyntaxErrorMessage(

Callers 3

getSyntaxErrorMessageFunction · 0.85
getLexicalErrorMessageFunction · 0.85

Calls 2

getLineAndColFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected