Fossil SCM
Improved error messages to background processes from the database interface.
Commit
72bb00bcab1d5a24bd0e5fcad785516b70cbd7bf93973b99e4fed28a2c3580d3
Parent
8a28a37c87a7a85…
1 file changed
+4
-15
M
src/db.c
+4
-15
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -73,11 +73,10 @@ | ||
| 73 | 73 | */ |
| 74 | 74 | static void db_err(const char *zFormat, ...){ |
| 75 | 75 | static int rcLooping = 0; |
| 76 | 76 | va_list ap; |
| 77 | 77 | char *z; |
| 78 | - int rc = 1; | |
| 79 | 78 | if( rcLooping ) exit(rcLooping); |
| 80 | 79 | va_start(ap, zFormat); |
| 81 | 80 | z = vmprintf(zFormat, ap); |
| 82 | 81 | va_end(ap); |
| 83 | 82 | #ifdef FOSSIL_ENABLE_JSON |
| @@ -87,26 +86,16 @@ | ||
| 87 | 86 | rc = 0 /* avoid HTTP 500 */; |
| 88 | 87 | } |
| 89 | 88 | } |
| 90 | 89 | else |
| 91 | 90 | #endif /* FOSSIL_ENABLE_JSON */ |
| 92 | - if( g.xferPanic ){ | |
| 91 | + if( g.xferPanic && g.cgiOutput==1 ){ | |
| 93 | 92 | cgi_reset_content(); |
| 94 | 93 | @ error Database\serror:\s%F(z) |
| 95 | - cgi_reply(); | |
| 96 | - } | |
| 97 | - else if( g.cgiOutput ){ | |
| 98 | - g.cgiOutput = 0; | |
| 99 | - cgi_printf("<h1>Database Error</h1>\n<p>%h</p>\n", z); | |
| 100 | - cgi_reply(); | |
| 101 | - }else{ | |
| 102 | - fprintf(stderr, "%s: %s\n", g.argv[0], z); | |
| 103 | - } | |
| 104 | - free(z); | |
| 105 | - rcLooping = rc; | |
| 106 | - db_force_rollback(); | |
| 107 | - fossil_exit(rc); | |
| 94 | + cgi_reply(); | |
| 95 | + } | |
| 96 | + fossil_panic("Database error: %s", z); | |
| 108 | 97 | } |
| 109 | 98 | |
| 110 | 99 | /* |
| 111 | 100 | ** All static variable that a used by only this file are gathered into |
| 112 | 101 | ** the following structure. |
| 113 | 102 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -73,11 +73,10 @@ | |
| 73 | */ |
| 74 | static void db_err(const char *zFormat, ...){ |
| 75 | static int rcLooping = 0; |
| 76 | va_list ap; |
| 77 | char *z; |
| 78 | int rc = 1; |
| 79 | if( rcLooping ) exit(rcLooping); |
| 80 | va_start(ap, zFormat); |
| 81 | z = vmprintf(zFormat, ap); |
| 82 | va_end(ap); |
| 83 | #ifdef FOSSIL_ENABLE_JSON |
| @@ -87,26 +86,16 @@ | |
| 87 | rc = 0 /* avoid HTTP 500 */; |
| 88 | } |
| 89 | } |
| 90 | else |
| 91 | #endif /* FOSSIL_ENABLE_JSON */ |
| 92 | if( g.xferPanic ){ |
| 93 | cgi_reset_content(); |
| 94 | @ error Database\serror:\s%F(z) |
| 95 | cgi_reply(); |
| 96 | } |
| 97 | else if( g.cgiOutput ){ |
| 98 | g.cgiOutput = 0; |
| 99 | cgi_printf("<h1>Database Error</h1>\n<p>%h</p>\n", z); |
| 100 | cgi_reply(); |
| 101 | }else{ |
| 102 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 103 | } |
| 104 | free(z); |
| 105 | rcLooping = rc; |
| 106 | db_force_rollback(); |
| 107 | fossil_exit(rc); |
| 108 | } |
| 109 | |
| 110 | /* |
| 111 | ** All static variable that a used by only this file are gathered into |
| 112 | ** the following structure. |
| 113 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -73,11 +73,10 @@ | |
| 73 | */ |
| 74 | static void db_err(const char *zFormat, ...){ |
| 75 | static int rcLooping = 0; |
| 76 | va_list ap; |
| 77 | char *z; |
| 78 | if( rcLooping ) exit(rcLooping); |
| 79 | va_start(ap, zFormat); |
| 80 | z = vmprintf(zFormat, ap); |
| 81 | va_end(ap); |
| 82 | #ifdef FOSSIL_ENABLE_JSON |
| @@ -87,26 +86,16 @@ | |
| 86 | rc = 0 /* avoid HTTP 500 */; |
| 87 | } |
| 88 | } |
| 89 | else |
| 90 | #endif /* FOSSIL_ENABLE_JSON */ |
| 91 | if( g.xferPanic && g.cgiOutput==1 ){ |
| 92 | cgi_reset_content(); |
| 93 | @ error Database\serror:\s%F(z) |
| 94 | cgi_reply(); |
| 95 | } |
| 96 | fossil_panic("Database error: %s", z); |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | ** All static variable that a used by only this file are gathered into |
| 101 | ** the following structure. |
| 102 |