diff --git a/browse/delete.go b/browse/delete.go index dc7ff36e..6e008ce3 100644 --- a/browse/delete.go +++ b/browse/delete.go @@ -28,7 +28,6 @@ func DELETE(w http.ResponseWriter, r *http.Request, c *config.Config) (int, erro // Check for errors if err != nil { - w.Write([]byte(err.Error())) return 500, err } } else { diff --git a/browse/post.go b/browse/post.go index 821be4c9..0c56cd7e 100644 --- a/browse/post.go +++ b/browse/post.go @@ -63,7 +63,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) if _, err := os.Stat(archetype + ".markdown"); err == nil { err = utils.CopyFile(archetype+".markdown", filename) if err != nil { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } @@ -77,7 +76,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) if _, err := os.Stat(archetype + ".md"); err == nil { err = utils.CopyFile(archetype+".md", filename) if err != nil { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } @@ -90,7 +88,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) wf, err := os.Create(filename) if err != nil { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } @@ -106,7 +103,6 @@ func upload(w http.ResponseWriter, r *http.Request, c *config.Config) (int, erro // Parse the multipart form in the request err := r.ParseMultipartForm(100000) if err != nil { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } @@ -117,20 +113,17 @@ func upload(w http.ResponseWriter, r *http.Request, c *config.Config) (int, erro // Open the first file var infile multipart.File if infile, err = hdr.Open(); nil != err { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } // Create the file var outfile *os.File if outfile, err = os.Create(c.Path + r.URL.Path + hdr.Filename); nil != err { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } // Copy the file content if _, err = io.Copy(outfile, infile); nil != err { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } diff --git a/editor/post.go b/editor/post.go index 6e4171bc..abba119d 100644 --- a/editor/post.go +++ b/editor/post.go @@ -34,7 +34,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config, filename str case "frontmatter-only": f, code, err := parseFrontMatterOnlyFile(rawFile, filename) if err != nil { - w.Write([]byte(err.Error())) return code, err } @@ -48,7 +47,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config, filename str case "complete": f, code, err := parseCompleteFile(r, c, rawFile, filename) if err != nil { - w.Write([]byte(err.Error())) return code, err } @@ -61,7 +59,6 @@ func POST(w http.ResponseWriter, r *http.Request, c *config.Config, filename str err := ioutil.WriteFile(filename, file, 0666) if err != nil { - w.Write([]byte(err.Error())) return http.StatusInternalServerError, err } diff --git a/hugo.go b/hugo.go index 409ea90f..9d0b679c 100644 --- a/hugo.go +++ b/hugo.go @@ -7,6 +7,7 @@ package hugo import ( + "log" "mime" "net/http" "os" @@ -141,6 +142,10 @@ func (h CaddyHugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error utils.Run(h.Config) } + if err != nil { + log.Panic(err) + } + return code, err } diff --git a/utils/utils.go b/utils/utils.go index 638d723f..bd9388f4 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -172,7 +172,7 @@ func Run(c *config.Config) { viper.Reset() commands.HugoCmd.ParseFlags(c.Args) if err := commands.HugoCmd.RunE(nil, nil); err != nil { - log.Print(err) + log.Panic(err) } }