diff options
author | Alexander Korotkov <akorotkov@postgresql.org> | 2019-04-23 17:43:09 +0300 |
---|---|---|
committer | Alexander Korotkov <akorotkov@postgresql.org> | 2019-05-08 01:02:59 +0300 |
commit | 29ceacc3f93720d3ebb7e7e999f8b7fe9622389c (patch) | |
tree | 578dcb45d91208e74a877a76a7638a047425ede7 /src/backend/utils/adt/jsonpath_scan.l | |
parent | b84dbc8eb80b43e554891c459a19969d9fbdefe5 (diff) |
Improve error reporting in jsonpath
This commit contains multiple improvements to error reporting in jsonpath
including but not limited to getting rid of following things:
* definition of error messages in macros,
* errdetail() when valueable information could fit to errmsg(),
* word "singleton" which is not properly explained anywhere,
* line breaks in error messages.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/14890.1555523005%40sss.pgh.pa.us
Author: Alexander Korotkov
Reviewed-by: Tom Lane
Diffstat (limited to 'src/backend/utils/adt/jsonpath_scan.l')
-rw-r--r-- | src/backend/utils/adt/jsonpath_scan.l | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l index 72bb5e3937b..6ab7c5c9c64 100644 --- a/src/backend/utils/adt/jsonpath_scan.l +++ b/src/backend/utils/adt/jsonpath_scan.l @@ -142,9 +142,9 @@ hex_fail \\x{hex_dig}{0,1} <xnq,xq,xvq,xsq>{hex_char} { parseHexChar(yytext); } -<xnq,xq,xvq,xsq>{unicode}*{unicodefail} { yyerror(NULL, "Unicode sequence is invalid"); } +<xnq,xq,xvq,xsq>{unicode}*{unicodefail} { yyerror(NULL, "invalid unicode sequence"); } -<xnq,xq,xvq,xsq>{hex_fail} { yyerror(NULL, "Hex character sequence is invalid"); } +<xnq,xq,xvq,xsq>{hex_fail} { yyerror(NULL, "invalid hex character sequence"); } <xnq,xq,xvq,xsq>{unicode}+\\ { /* throw back the \\, and treat as unicode */ @@ -152,11 +152,11 @@ hex_fail \\x{hex_dig}{0,1} parseUnicode(yytext, yyleng); } -<xnq,xq,xvq,xsq>\\. { yyerror(NULL, "Escape sequence is invalid"); } +<xnq,xq,xvq,xsq>\\. { yyerror(NULL, "escape sequence is invalid"); } -<xnq,xq,xvq,xsq>\\ { yyerror(NULL, "Unexpected end after backslash"); } +<xnq,xq,xvq,xsq>\\ { yyerror(NULL, "unexpected end after backslash"); } -<xq,xvq,xsq><<EOF>> { yyerror(NULL, "Unexpected end of quoted string"); } +<xq,xvq,xsq><<EOF>> { yyerror(NULL, "unexpected end of quoted string"); } <xq>\" { yylval->str = scanstring; @@ -186,7 +186,7 @@ hex_fail \\x{hex_dig}{0,1} <xc>\* { } -<xc><<EOF>> { yyerror(NULL, "Unexpected end of comment"); } +<xc><<EOF>> { yyerror(NULL, "unexpected end of comment"); } \&\& { return AND_P; } @@ -261,7 +261,7 @@ hex_fail \\x{hex_dig}{0,1} return INT_P; } -({realfail1}|{realfail2}) { yyerror(NULL, "Floating point number is invalid"); } +({realfail1}|{realfail2}) { yyerror(NULL, "invalid floating point number"); } {any}+ { addstring(true, yytext, yyleng); @@ -295,17 +295,16 @@ jsonpath_yyerror(JsonPathParseResult **result, const char *message) { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("bad jsonpath representation"), /* translator: %s is typically "syntax error" */ - errdetail("%s at end of input", message))); + errmsg("%s at end of jsonpath input", _(message)))); } else { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("bad jsonpath representation"), /* translator: first %s is typically "syntax error" */ - errdetail("%s at or near \"%s\"", message, yytext))); + errmsg("%s at or near \"%s\" of jsonpath input", + _(message), yytext))); } } @@ -495,7 +494,7 @@ hexval(char c) return c - 'a' + 0xA; if (c >= 'A' && c <= 'F') return c - 'A' + 0xA; - elog(ERROR, "invalid hexadecimal digit"); + jsonpath_yyerror(NULL, "invalid hexadecimal digit"); return 0; /* not reached */ } |