From: Vincent Batoufflet Date: Sun, 26 Jan 2014 09:48:00 +0000 (+0100) Subject: Fix panic with HTTP serve initialization problems. X-Git-Tag: v0.10~38 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ff9f6e1b2a000a24e677b9a3fa8dfbdef11c404c;p=brevno-suite%2Fhugo Fix panic with HTTP serve initialization problems. --- diff --git a/commands/server.go b/commands/server.go index cb33aedf..5ae518ee 100644 --- a/commands/server.go +++ b/commands/server.go @@ -17,6 +17,7 @@ import ( "fmt" "github.com/spf13/cobra" "net/http" + "os" "strconv" "strings" ) @@ -83,5 +84,10 @@ func serve(port int) { } fmt.Println("Press ctrl+c to stop") - panic(http.ListenAndServe(":"+strconv.Itoa(port), http.FileServer(http.Dir(Config.GetAbsPath(Config.PublishDir))))) + + err := http.ListenAndServe(":"+strconv.Itoa(port), http.FileServer(http.Dir(Config.GetAbsPath(Config.PublishDir)))) + if err != nil { + fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error()) + os.Exit(1) + } }