Improved error message formatting in the shell. Distinguish between

"Parse errors" and "Runtime errors".

FossilOrigin-Name: ae3e322a029952f575e49c73fb50b46bbea55be6792cc225cb94f5e0cbd046d9
This commit is contained in:
drh 2022-02-08 11:52:45 +00:00
parent e1c4743121
commit 3e46db21d4
5 changed files with 31 additions and 20 deletions

View File

@ -1,5 +1,5 @@
C Disable\sthe\ssqlite3_error_offset()\swhen\sthe\serror\soccurs\sin\sa\strigger\sor\nview\sor\ssome\sother\sbit\sof\stext\sthat\sis\snot\spart\sof\sthe\soriginal\sstatement. C Improved\serror\smessage\sformatting\sin\sthe\sshell.\s\sDistinguish\sbetween\n"Parse\serrors"\sand\s"Runtime\serrors".
D 2022-02-07T18:52:56.839 D 2022-02-08T11:52:45.141
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -553,7 +553,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c 3baa9dd8cf240654773c7974e2bcce398ac9dd24419c36684156963defe43b35 F src/select.c 3baa9dd8cf240654773c7974e2bcce398ac9dd24419c36684156963defe43b35
F src/shell.c.in 2f58e6aa6b3d2012db32f1c5fa4591e9d12fd582904632b4fc8f57a382b98fd3 F src/shell.c.in 0ea8af78103ea178a91be97c75c3ee6b9d78144bccb52909e17d1fa3a0f356cb
F src/sqlite.h.in 800d6509517d383d38188e71bb5f1802c7db097a1282af7bf5d6c9a6da5a15ed F src/sqlite.h.in 800d6509517d383d38188e71bb5f1802c7db097a1282af7bf5d6c9a6da5a15ed
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6 F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6
@ -1388,8 +1388,8 @@ F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939 F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304 F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
F test/shell1.test ce2f370886645f38fabdde44976c14a004400f166edea8fdd9741079b645fef6 F test/shell1.test ce2f370886645f38fabdde44976c14a004400f166edea8fdd9741079b645fef6
F test/shell2.test f00a0501c00583cbc46f7510e1d713366326b2b3e63d06d15937284171a8787c F test/shell2.test c9d6b6d6577662290aa9786ae3862133f257d9505573ef67147b2717eefce05a
F test/shell3.test cb4b835a901742c9719437a89171172ecc4a8823ad97349af8e4e841e6f82566 F test/shell3.test 4d8658a6b3f5541663a4d6047612e39210df16f0f0594c888d132fa272ccdec5
F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759 F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
F test/shell5.test b85069bfcf3159b225228629ab2c3e69aa923d098fea8ea074b5dcd743522e2c F test/shell5.test b85069bfcf3159b225228629ab2c3e69aa923d098fea8ea074b5dcd743522e2c
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3 F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
@ -1943,8 +1943,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 9a206e37fb49a203a7b5fdc93c41acc39e9ceb37144c78432a235e2f0d54a210 P 0e909e34fa74e7b9b7954e4ed4c39dd293c1d413b58fda03607faab74aa382ad
R 0bec0c5635c3eb23a485bd776e87820e R d18f19d6b0d587687fe303ed881a44cc
U drh U drh
Z 0f4df12d4ecf241bfbf3b48f4a3650a9 Z e5c99d42cfc720230961c3936a9ada21
# Remove this line to create a well-formed Fossil manifest. # Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
0e909e34fa74e7b9b7954e4ed4c39dd293c1d413b58fda03607faab74aa382ad ae3e322a029952f575e49c73fb50b46bbea55be6792cc225cb94f5e0cbd046d9

View File

@ -11179,19 +11179,30 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
END_TIMER; END_TIMER;
if( rc || zErrMsg ){ if( rc || zErrMsg ){
char zPrefix[100]; char zPrefix[100];
const char *zErrorTail;
const char *zErrorType;
if( zErrMsg==0 ){
zErrorType = "Error";
zErrorTail = sqlite3_errmsg(p->db);
}else if( strncmp(zErrMsg, "in prepare, ",12)==0 ){
zErrorType = "Parse error";
zErrorTail = &zErrMsg[12];
}else if( strncmp(zErrMsg, "stepping, ", 10)==0 ){
zErrorType = "Runtime error";
zErrorTail = &zErrMsg[10];
}else{
zErrorType = "Error";
zErrorTail = zErrMsg;
}
if( in!=0 || !stdin_is_interactive ){ if( in!=0 || !stdin_is_interactive ){
sqlite3_snprintf(sizeof(zPrefix), zPrefix, sqlite3_snprintf(sizeof(zPrefix), zPrefix,
"Error: near line %d:", startline); "%s near line %d:", zErrorType, startline);
}else{ }else{
sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:"); sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
}
if( zErrMsg!=0 ){
utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg);
sqlite3_free(zErrMsg);
zErrMsg = 0;
}else{
utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
} }
utf8_printf(stderr, "%s %s\n", zPrefix, zErrorTail);
sqlite3_free(zErrMsg);
zErrMsg = 0;
return 1; return 1;
}else if( ShellHasFlag(p, SHFLG_CountChanges) ){ }else if( ShellHasFlag(p, SHFLG_CountChanges) ){
char zLineBuf[2000]; char zLineBuf[2000];

View File

@ -63,7 +63,7 @@ do_test shell2-1.3 {
UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1; UPDATE OR REPLACE t5 SET a = 4 WHERE a = 1;
} }
} {1 {Error: near line 9: stepping, too many levels of trigger recursion (1)}} } {1 {Runtime error near line 9: too many levels of trigger recursion (1)}}

View File

@ -98,7 +98,7 @@ do_test shell3-2.6 {
} {0 {}} } {0 {}}
do_test shell3-2.7 { do_test shell3-2.7 {
catchcmd "foo.db" "CREATE TABLE" catchcmd "foo.db" "CREATE TABLE"
} {1 {Error: near line 1: in prepare, incomplete input (1)}} } {1 {Parse error near line 1: incomplete input (1)}}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------