Resolve the possible panic caused by the document server

This commit is contained in:
2025-11-27 22:43:00 +08:00
parent 4697c98954
commit 4ae50798ab
3 changed files with 13 additions and 6 deletions

View File

@@ -68,9 +68,7 @@ func staticFileHandler(w http.ResponseWriter, r *http.Request) {
// Clean path, make sure it starts with "docs/"
path = strings.TrimPrefix(path, "/")
if path == "" {
if err := notFoundTemplate.Execute(w, ""); err != nil {
log.Printf("[Error] Failed to render error page: %v", err)
}
notFoundHandler(w, r)
return
}
@@ -79,9 +77,7 @@ func staticFileHandler(w http.ResponseWriter, r *http.Request) {
data, err := webFiles.ReadFile(filePath)
if err != nil {
log.Printf("[Error] Static file not found: %s", filePath)
if err := notFoundTemplate.Execute(w, ""); err != nil {
log.Printf("[Error] Failed to render error page: %v", err)
}
notFoundHandler(w, r)
return
}