From 0a70827a6042e6a897534e216f0da354e382c993 Mon Sep 17 00:00:00 2001 From: Vincent Batoufflet Date: Sun, 26 Jan 2014 10:48:00 +0100 Subject: [PATCH] Fix panic with HTTP serve initialization problems. --- commands/server.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/commands/server.go b/commands/server.go index cb33aedff..5ae518eef 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) + } }