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
No related branches found
No related tags found
No related merge requests found
......@@ -126,23 +126,23 @@ func errorHandler(errorFilesPath string) func(http.ResponseWriter, *http.Request
if err != nil {
code = 404
log.Printf("unexpected error reading return code: %v. Using %v", err, code)
err = nil
}
w.WriteHeader(code)
var file string
for _, ext := range exts {
filePath := fmt.Sprintf("%v/%v%v", errorFilesPath, code, ext)
if _, err := os.Stat(file); os.IsExist(err) {
file = filePath
break
}
if _, err := os.Stat(file); os.IsNotExist(err) {
scode := strconv.Itoa(code)
filePath = fmt.Sprintf("%v/%cxx%v", errorFilesPath, scode[0], ext)
if _, err := os.Stat(file); os.IsExist(err) {
continue
}
}
file = filePath
break
}
}
if file == "" {
log.Printf("unexpected error opening file: %v", err)
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