mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Print errors through LOG_ERROR
This commit is contained in:
parent
1b37d7716f
commit
066242c64d
@ -1,4 +1,5 @@
|
||||
#include <Common/Exception.h>
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
#include <Parsers/New/LexerErrorListener.h>
|
||||
|
||||
@ -17,7 +18,7 @@ extern int SYNTAX_ERROR;
|
||||
|
||||
void LexerErrorListener::syntaxError(Recognizer *, Token *, size_t, size_t, const std::string & message, std::exception_ptr)
|
||||
{
|
||||
std::cerr << "Lexer error: " << message << std::endl;
|
||||
LOG_ERROR(&Poco::Logger::get("ClickHouseLexer"), "Lexer error: {}", message);
|
||||
|
||||
throw DB::Exception("Can't recognize input: " + message, ErrorCodes::SYNTAX_ERROR);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <Common/Exception.h>
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
#include <Parsers/New/ParserErrorListener.h>
|
||||
|
||||
@ -24,9 +25,10 @@ void ParserErrorListener::syntaxError(
|
||||
{
|
||||
auto * parser = dynamic_cast<ClickHouseParser*>(recognizer);
|
||||
|
||||
std::cerr << "Last element parsed so far:" << std::endl
|
||||
<< parser->getRuleContext()->toStringTree(parser, true) << std::endl
|
||||
<< "Parser error: (pos " << token->getStartIndex() << ") " << message << std::endl;
|
||||
LOG_ERROR(&Poco::Logger::get("ClickHouseParser"),
|
||||
"Last element parsed so far:\n"
|
||||
"{}\n"
|
||||
"Parser error: (pos {}) {}", parser->getRuleContext()->toStringTree(parser, true), token->getStartIndex(), message);
|
||||
|
||||
throw DB::Exception("Can't parse input: " + message, ErrorCodes::SYNTAX_ERROR);
|
||||
}
|
||||
|
12
src/Parsers/New/README.md
Normal file
12
src/Parsers/New/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
## How to generate source code files from grammar
|
||||
|
||||
Grammar is located inside `ClickHouseLexer.g4` and `ClickHouseParser.g4` files.
|
||||
|
||||
To generate source code you need to install locally the `antlr4` binary:
|
||||
```
|
||||
cd src/Parsers/New
|
||||
antlr4 -no-listener -visitor -package DB -Dlanguage=Cpp ClickHouseLexer.g4 # if you have changes in a lexer part of grammar
|
||||
antlr4 -no-listener -visitor -package DB -Dlanguage=Cpp ClickHouseParser.g4
|
||||
```
|
||||
|
||||
Commit only git-tracked generated files - not all of the generated content is required.
|
Loading…
Reference in New Issue
Block a user