Kouhei Sutou
null+****@clear*****
Thu Mar 30 16:51:25 JST 2017
Kouhei Sutou 2017-03-30 16:51:25 +0900 (Thu, 30 Mar 2017) New Revision: bb6c906d1459e22deca38c67f55740b11bdf0567 https://github.com/groonga/groonga/commit/bb6c906d1459e22deca38c67f55740b11bdf0567 Message: expr: improve error message Modified files: lib/expr.c test/unit/core/test-command-delete.c test/unit/core/test-expr-script.c Modified: lib/expr.c (+14 -14) =================================================================== --- lib/expr.c 2017-03-30 16:14:23 +0900 (1b188ff) +++ lib/expr.c 2017-03-30 16:51:25 +0900 (a6d9a01) @@ -7464,7 +7464,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'*=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'*=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7481,7 +7481,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'++' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'++' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; case '=' : @@ -7490,7 +7490,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'+=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'+=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7507,7 +7507,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'--' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'--' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; case '=' : @@ -7516,7 +7516,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'-=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'-=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7537,7 +7537,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'|=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'|=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7554,7 +7554,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'/=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'/=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7571,7 +7571,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'%%=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'%%=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7600,7 +7600,7 @@ parse_script(grn_ctx *ctx, efs_info *q) PARSE(GRN_EXPR_TOKEN_XOR_ASSIGN); } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'^=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'^=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7621,7 +7621,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 2; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'&=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'&=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; case '!' : @@ -7646,7 +7646,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 4; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'>>>=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'>>>=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7661,7 +7661,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 3; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'>>=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'>>=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7690,7 +7690,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur += 3; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'<<=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'<<=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; default : @@ -7721,7 +7721,7 @@ parse_script(grn_ctx *ctx, efs_info *q) q->cur++; } else { ERR(GRN_UPDATE_NOT_ALLOWED, - "'=' is not allowed (%.*s)", (int)(q->str_end - q->str), q->str); + "'=' is not allowed: <%.*s>", (int)(q->str_end - q->str), q->str); } break; } Modified: test/unit/core/test-command-delete.c (+2 -1) =================================================================== --- test/unit/core/test-command-delete.c 2017-03-30 16:14:23 +0900 (2fad6eb) +++ test/unit/core/test-command-delete.c 2017-03-30 16:51:25 +0900 (648255c) @@ -383,6 +383,7 @@ test_invalid_filter(void) context, GRN_SYNTAX_ERROR, "[table][record][delete] failed to parse filter: " - "table: <Users>, filter: <$>, detail: <Syntax error: <$||>>", + "table: <Users>, filter: <$>, detail: <Syntax error: <$||>: " + "[expr][parse] unknow", "delete Users --filter \"$\""); } Modified: test/unit/core/test-expr-script.c (+28 -21) =================================================================== --- test/unit/core/test-expr-script.c 2017-03-30 16:14:23 +0900 (84e8653) +++ test/unit/core/test-expr-script.c 2017-03-30 16:51:25 +0900 (767b0fe) @@ -393,7 +393,8 @@ data_comparison_operator_syntax_error(void) NULL) ADD_DATUM("nonexistent ==", - cut_take_printf("Syntax error: <nonexistent| |== 100>"), + cut_take_printf("Syntax error: <nonexistent| |== 100>: " + "[expr][parse] unknown identifier: <nonexistent>"), "nonexistent == 100"); #undef ADD_DATUM @@ -1348,16 +1349,20 @@ data_arithmetic_operator_syntax_error(void) NULL) ADD_DATUM("++constant", - cut_take_printf("constant can't be incremented: <++8 <= 9>"), + cut_take_printf("Syntax error: <++8 <=| |9>: " + "constant can't be incremented: <++8 <= 9>"), "++8 <= 9"); ADD_DATUM("--constant", - cut_take_printf("constant can't be decremented: <--10 <= 9>"), + cut_take_printf("Syntax error: <--10 <=| |9>: " + "constant can't be decremented: <--10 <= 9>"), "--10 <= 9"); ADD_DATUM("constant++", - cut_take_printf("constant can't be incremented: <8++ <= 9>"), + cut_take_printf("Syntax error: <8++ <=| |9>: " + "constant can't be incremented: <8++ <= 9>"), "8++ <= 9"); ADD_DATUM("constant--", - cut_take_printf("constant can't be decremented: <10-- <= 9>"), + cut_take_printf("Syntax error: <10-- <=| |9>: " + "constant can't be decremented: <10-- <= 9>"), "10-- <= 9"); #undef ADD_DATUM @@ -1393,52 +1398,54 @@ data_not_allow_update(void) NULL) ADD_DATUM("=", - cut_take_printf("'=' is not allowed (size = 100)"), + cut_take_printf("'=' is not allowed: <size = 100>"), "size = 100"); ADD_DATUM("*=", - cut_take_printf("'*=' is not allowed (size *= 10)"), + cut_take_printf("'*=' is not allowed: <size *= 10>"), "size *= 10"); ADD_DATUM("/=", - cut_take_printf("'/=' is not allowed (size /= 10)"), + cut_take_printf("'/=' is not allowed: <size /= 10>"), "size /= 10"); ADD_DATUM("%=", - cut_take_printf("'%%=' is not allowed (size %%= 10)"), + cut_take_printf("'%%=' is not allowed: <size %%= 10>"), "size %= 10"); ADD_DATUM("+=", - cut_take_printf("'+=' is not allowed (size += 10)"), + cut_take_printf("'+=' is not allowed: <size += 10>"), "size += 10"); ADD_DATUM("-=", - cut_take_printf("'-=' is not allowed (size -= 10)"), + cut_take_printf("'-=' is not allowed: <size -= 10>"), "size -= 10"); ADD_DATUM("<<=", - cut_take_printf("'<<=' is not allowed (size <<= 10)"), + cut_take_printf("'<<=' is not allowed: <size <<= 10>"), "size <<= 10"); ADD_DATUM(">>=", - cut_take_printf("'>>=' is not allowed (size >>= 10)"), + cut_take_printf("'>>=' is not allowed: <size >>= 10>"), "size >>= 10"); ADD_DATUM(">>>=", - cut_take_printf("'>>>=' is not allowed (size >>>= 10)"), + cut_take_printf("'>>>=' is not allowed: <size >>>= 10>"), "size >>>= 10"); ADD_DATUM("&=", - cut_take_printf("'&=' is not allowed (size &= 10)"), + cut_take_printf("'&=' is not allowed: <size &= 10>"), "size &= 10"); ADD_DATUM("|=", - cut_take_printf("'|=' is not allowed (size |= 10)"), + cut_take_printf("'|=' is not allowed: <size |= 10>"), "size |= 10"); ADD_DATUM("^=", - cut_take_printf("'^=' is not allowed (size ^= 10)"), + cut_take_printf("'^=' is not allowed: <size ^= 10>"), "size ^= 10"); ADD_DATUM("variable++", - cut_take_printf("'++' is not allowed (size++)"), + cut_take_printf("'++' is not allowed: <size++>"), "size++"); ADD_DATUM("++variable", - cut_take_printf("'++' is not allowed (++size)"), + cut_take_printf("Syntax error: <|+|+size>: " + "'++' is not allowed: <++size>"), "++size"); ADD_DATUM("variable--", - cut_take_printf("'--' is not allowed (size--)"), + cut_take_printf("'--' is not allowed: <size-->"), "size--"); ADD_DATUM("--variable", - cut_take_printf("'--' is not allowed (--size)"), + cut_take_printf("Syntax error: <|-|-size>: " + "'--' is not allowed: <--size>"), "--size"); #undef ADD_DATUM -------------- next part -------------- HTML����������������������������...Download