shithub: hugo

Download patch

ref: ff9f6e1b2a000a24e677b9a3fa8dfbdef11c404c
parent: 0ce6f05f59213c460ec451020899afba35f67bd0
author: Vincent Batoufflet <[email protected]>
date: Sun Jan 26 05:48:00 EST 2014

Fix panic with HTTP serve initialization problems.

--- a/commands/server.go
+++ b/commands/server.go
@@ -17,6 +17,7 @@
 	"fmt"
 	"github.com/spf13/cobra"
 	"net/http"
+	"os"
 	"strconv"
 	"strings"
 )
@@ -83,5 +84,10 @@
 	}
 
 	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)
+	}
 }