diff --git a/main.go b/main.go
index 1fc15dabdb14166d965cf31e59aaef2cb6bc8265..91fea4a452c9923099a405e8cfb41154260cbdab 100644
--- a/main.go
+++ b/main.go
@@ -108,8 +108,10 @@ func errorHandler(errorFilesPath string) func(http.ResponseWriter, *http.Request
 
 		cext, err := mime.ExtensionsByType(format)
 		if err != nil {
+			format = "text/html"
 			log.Printf("unexpected error reading media type extension: %v. Using %v", err, strings.Join(exts, ", "))
 		} else if len(cext) == 0 {
+			format = "text/html"
 			log.Printf("couldn't get media type extension. Using %v", strings.Join(exts, ", "))
 		} else {
 			exts = cext