Skip to content
Snippets Groups Projects
Verified Commit 6cff08ed authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Attempt to fix error handling

parent 4dc2bdb5
Branches
No related tags found
No related merge requests found
...@@ -126,23 +126,23 @@ func errorHandler(errorFilesPath string) func(http.ResponseWriter, *http.Request ...@@ -126,23 +126,23 @@ func errorHandler(errorFilesPath string) func(http.ResponseWriter, *http.Request
if err != nil { if err != nil {
code = 404 code = 404
log.Printf("unexpected error reading return code: %v. Using %v", err, code) log.Printf("unexpected error reading return code: %v. Using %v", err, code)
err = nil
} }
w.WriteHeader(code) w.WriteHeader(code)
var file string var file string
for _, ext := range exts { for _, ext := range exts {
filePath := fmt.Sprintf("%v/%v%v", errorFilesPath, code, ext) filePath := fmt.Sprintf("%v/%v%v", errorFilesPath, code, ext)
if _, err := os.Stat(file); os.IsExist(err) { if _, err := os.Stat(file); os.IsNotExist(err) {
file = filePath
break
}
scode := strconv.Itoa(code) scode := strconv.Itoa(code)
filePath = fmt.Sprintf("%v/%cxx%v", errorFilesPath, scode[0], ext) filePath = fmt.Sprintf("%v/%cxx%v", errorFilesPath, scode[0], ext)
if _, err := os.Stat(file); os.IsExist(err) { if _, err := os.Stat(file); os.IsExist(err) {
continue
}
}
file = filePath file = filePath
break break
} }
}
if file == "" { if file == "" {
log.Printf("unexpected error opening file: %v", err) log.Printf("unexpected error opening file: %v", err)
http.NotFound(w, r) http.NotFound(w, r)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment