Fossil SCM
Improved error messages from the forum when the forum artifact ID is incorrect.
Commit
93a5d659b350fd9d0f60a4d39aaf565fc42512eaa38a33fc88baef4e417b537c
Parent
2b1c5bc8fe80f70…
2 files changed
+8
-3
+19
+8
-3
| --- src/forum.c | ||
| +++ src/forum.c | ||
| @@ -287,11 +287,11 @@ | ||
| 287 | 287 | fpid = symbolic_name_to_rid(zName, "f"); |
| 288 | 288 | if( fpid<=0 ){ |
| 289 | 289 | fpid = db_int(0, "SELECT rid FROM blob WHERE rid=%d", atoi(zName)); |
| 290 | 290 | } |
| 291 | 291 | if( fpid<=0 ){ |
| 292 | - fossil_fatal("Unknown or ambiguous forum id: \"%s\"", zName); | |
| 292 | + fossil_fatal("unknown or ambiguous forum id: \"%s\"", zName); | |
| 293 | 293 | } |
| 294 | 294 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 295 | 295 | if( froot==0 ){ |
| 296 | 296 | fossil_fatal("Not a forum post: \"%s\"", zName); |
| 297 | 297 | } |
| @@ -813,15 +813,20 @@ | ||
| 813 | 813 | if( zName==0 ){ |
| 814 | 814 | webpage_error("Missing \"name=\" query parameter"); |
| 815 | 815 | } |
| 816 | 816 | fpid = symbolic_name_to_rid(zName, "f"); |
| 817 | 817 | if( fpid<=0 ){ |
| 818 | - webpage_error("Unknown or ambiguous forum id: \"%s\"", zName); | |
| 818 | + if( fpid==0 ){ | |
| 819 | + webpage_notfound_error("Unknown forum id: \"%s\"", zName); | |
| 820 | + }else{ | |
| 821 | + ambiguous_page(); | |
| 822 | + } | |
| 823 | + return; | |
| 819 | 824 | } |
| 820 | 825 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 821 | 826 | if( froot==0 ){ |
| 822 | - webpage_error("Not a forum post: \"%s\"", zName); | |
| 827 | + webpage_notfound_error("Not a forum post: \"%s\"", zName); | |
| 823 | 828 | } |
| 824 | 829 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| 825 | 830 | |
| 826 | 831 | /* Decode the mode parameters. */ |
| 827 | 832 | if( bRaw ){ |
| 828 | 833 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -287,11 +287,11 @@ | |
| 287 | fpid = symbolic_name_to_rid(zName, "f"); |
| 288 | if( fpid<=0 ){ |
| 289 | fpid = db_int(0, "SELECT rid FROM blob WHERE rid=%d", atoi(zName)); |
| 290 | } |
| 291 | if( fpid<=0 ){ |
| 292 | fossil_fatal("Unknown or ambiguous forum id: \"%s\"", zName); |
| 293 | } |
| 294 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 295 | if( froot==0 ){ |
| 296 | fossil_fatal("Not a forum post: \"%s\"", zName); |
| 297 | } |
| @@ -813,15 +813,20 @@ | |
| 813 | if( zName==0 ){ |
| 814 | webpage_error("Missing \"name=\" query parameter"); |
| 815 | } |
| 816 | fpid = symbolic_name_to_rid(zName, "f"); |
| 817 | if( fpid<=0 ){ |
| 818 | webpage_error("Unknown or ambiguous forum id: \"%s\"", zName); |
| 819 | } |
| 820 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 821 | if( froot==0 ){ |
| 822 | webpage_error("Not a forum post: \"%s\"", zName); |
| 823 | } |
| 824 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| 825 | |
| 826 | /* Decode the mode parameters. */ |
| 827 | if( bRaw ){ |
| 828 |
| --- src/forum.c | |
| +++ src/forum.c | |
| @@ -287,11 +287,11 @@ | |
| 287 | fpid = symbolic_name_to_rid(zName, "f"); |
| 288 | if( fpid<=0 ){ |
| 289 | fpid = db_int(0, "SELECT rid FROM blob WHERE rid=%d", atoi(zName)); |
| 290 | } |
| 291 | if( fpid<=0 ){ |
| 292 | fossil_fatal("unknown or ambiguous forum id: \"%s\"", zName); |
| 293 | } |
| 294 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 295 | if( froot==0 ){ |
| 296 | fossil_fatal("Not a forum post: \"%s\"", zName); |
| 297 | } |
| @@ -813,15 +813,20 @@ | |
| 813 | if( zName==0 ){ |
| 814 | webpage_error("Missing \"name=\" query parameter"); |
| 815 | } |
| 816 | fpid = symbolic_name_to_rid(zName, "f"); |
| 817 | if( fpid<=0 ){ |
| 818 | if( fpid==0 ){ |
| 819 | webpage_notfound_error("Unknown forum id: \"%s\"", zName); |
| 820 | }else{ |
| 821 | ambiguous_page(); |
| 822 | } |
| 823 | return; |
| 824 | } |
| 825 | froot = db_int(0, "SELECT froot FROM forumpost WHERE fpid=%d", fpid); |
| 826 | if( froot==0 ){ |
| 827 | webpage_notfound_error("Not a forum post: \"%s\"", zName); |
| 828 | } |
| 829 | if( fossil_strcmp(g.zPath,"forumthread")==0 ) fpid = 0; |
| 830 | |
| 831 | /* Decode the mode parameters. */ |
| 832 | if( bRaw ){ |
| 833 |
+19
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -1226,10 +1226,29 @@ | ||
| 1226 | 1226 | void webpage_assert_page(const char *zFile, int iLine, const char *zExpr){ |
| 1227 | 1227 | fossil_warning("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1228 | 1228 | cgi_reset_content(); |
| 1229 | 1229 | webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1230 | 1230 | } |
| 1231 | + | |
| 1232 | +/* | |
| 1233 | +** Issue a 404 Not Found error for a webpage | |
| 1234 | +*/ | |
| 1235 | +void webpage_notfound_error(const char *zFormat, ...){ | |
| 1236 | + char *zMsg; | |
| 1237 | + va_list ap; | |
| 1238 | + if( zFormat ){ | |
| 1239 | + va_start(ap, zFormat); | |
| 1240 | + zMsg = vmprintf(zFormat, ap); | |
| 1241 | + va_end(ap); | |
| 1242 | + }else{ | |
| 1243 | + zMsg = "Not Found"; | |
| 1244 | + } | |
| 1245 | + style_header("Not Found"); | |
| 1246 | + @ <p>%h(zMsg)</p> | |
| 1247 | + cgi_set_status(404, "Not Found"); | |
| 1248 | + style_finish_page("enotfound"); | |
| 1249 | +} | |
| 1231 | 1250 | |
| 1232 | 1251 | #if INTERFACE |
| 1233 | 1252 | # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);} |
| 1234 | 1253 | #endif |
| 1235 | 1254 | |
| 1236 | 1255 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1226,10 +1226,29 @@ | |
| 1226 | void webpage_assert_page(const char *zFile, int iLine, const char *zExpr){ |
| 1227 | fossil_warning("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1228 | cgi_reset_content(); |
| 1229 | webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1230 | } |
| 1231 | |
| 1232 | #if INTERFACE |
| 1233 | # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);} |
| 1234 | #endif |
| 1235 | |
| 1236 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1226,10 +1226,29 @@ | |
| 1226 | void webpage_assert_page(const char *zFile, int iLine, const char *zExpr){ |
| 1227 | fossil_warning("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1228 | cgi_reset_content(); |
| 1229 | webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr); |
| 1230 | } |
| 1231 | |
| 1232 | /* |
| 1233 | ** Issue a 404 Not Found error for a webpage |
| 1234 | */ |
| 1235 | void webpage_notfound_error(const char *zFormat, ...){ |
| 1236 | char *zMsg; |
| 1237 | va_list ap; |
| 1238 | if( zFormat ){ |
| 1239 | va_start(ap, zFormat); |
| 1240 | zMsg = vmprintf(zFormat, ap); |
| 1241 | va_end(ap); |
| 1242 | }else{ |
| 1243 | zMsg = "Not Found"; |
| 1244 | } |
| 1245 | style_header("Not Found"); |
| 1246 | @ <p>%h(zMsg)</p> |
| 1247 | cgi_set_status(404, "Not Found"); |
| 1248 | style_finish_page("enotfound"); |
| 1249 | } |
| 1250 | |
| 1251 | #if INTERFACE |
| 1252 | # define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);} |
| 1253 | #endif |
| 1254 | |
| 1255 |