mirror of https://gitee.com/bigwinds/arangodb
Parser: when throwing parse exceptions add the query and a pointer to the actual indicated error to the message.
This commit is contained in:
parent
8ec9525c05
commit
ec67a07f9b
|
@ -178,15 +178,35 @@ void Parser::registerParseError (int errorCode,
|
|||
// extract the query string part where the error happened
|
||||
std::string const region(_query->extractRegion(line, column));
|
||||
|
||||
// create a neat pointer to the location of the error.
|
||||
auto arrowpointer = (char*) malloc (sizeof(char) * (column + 10) );
|
||||
size_t i;
|
||||
for (i = 0; i < (size_t) column; i++) {
|
||||
arrowpointer[i] = ' ';
|
||||
}
|
||||
if (i > 0) {
|
||||
i --;
|
||||
arrowpointer[i++] = '^';
|
||||
}
|
||||
|
||||
arrowpointer[i++] = '^';
|
||||
arrowpointer[i++] = '^';
|
||||
arrowpointer[i++] = '\0';
|
||||
|
||||
|
||||
// note: line numbers reported by bison/flex start at 1, columns start at 0
|
||||
char buffer[512];
|
||||
snprintf(buffer,
|
||||
sizeof(buffer),
|
||||
"%s near '%s' at position %d:%d",
|
||||
"%s near '%s' at position %d:%d:\n%s\n%s\n",
|
||||
data,
|
||||
region.c_str(),
|
||||
line,
|
||||
column + 1);
|
||||
column + 1,
|
||||
_query->queryString(),
|
||||
arrowpointer);
|
||||
|
||||
free(arrowpointer);
|
||||
|
||||
registerError(errorCode, buffer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue