MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AST_ReportErrors

Function AST_ReportErrors

src/ast/ast_validations.c:2308–2337  ·  view source on GitHub ↗

report encountered errors by libcypher-parser

Source from the content-addressed store, hash-verified

2306
2307// report encountered errors by libcypher-parser
2308void AST_ReportErrors
2309(
2310 const cypher_parse_result_t *result // parse-result
2311) {
2312 ASSERT(cypher_parse_result_nerrors(result) > 0);
2313
2314 // report first encountered error
2315 const cypher_parse_error_t *error =
2316 cypher_parse_result_get_error(result, 0);
2317
2318 // Get the position of an error.
2319 struct cypher_input_position errPos = cypher_parse_error_position(error);
2320
2321 // Get the error message of an error.
2322 const char *errMsg = cypher_parse_error_message(error);
2323
2324 // Get the error context of an error.
2325 // This returns a pointer to a null-terminated string, which contains a
2326 // section of the input around where the error occurred, that is limited
2327 // in length and suitable for presentation to a user.
2328 const char *errCtx = cypher_parse_error_context(error);
2329
2330 // Get the offset into the context of an error.
2331 // Identifies the point of the error within the context string, allowing
2332 // this to be reported to the user, typically with an arrow pointing to the
2333 // invalid character.
2334 size_t errCtxOffset = cypher_parse_error_context_offset(error);
2335 ErrorCtx_SetError("errMsg: %s line: %u, column: %u, offset: %zu errCtx: %s errCtxOffset: %zu",
2336 errMsg, errPos.line, errPos.column, errPos.offset, errCtx, errCtxOffset);
2337}

Callers 1

parse_queryFunction · 0.85

Calls 1

ErrorCtx_SetErrorFunction · 0.85

Tested by

no test coverage detected