Readded missing exit-handling function
This commit is contained in:
parent
731f1a6791
commit
c61eeb004a
|
@ -5,7 +5,7 @@ Copyright © 2022 Seednode <seednode@seedno.de>
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -26,8 +26,7 @@ var rootCmd = &cobra.Command{
|
|||
func Execute() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
panic(Exit{1})
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
cmd/web.go
11
cmd/web.go
|
@ -16,6 +16,17 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
type Exit struct{ Code int }
|
||||
|
||||
func HandleExit() {
|
||||
if e := recover(); e != nil {
|
||||
if exit, ok := e.(Exit); ok == true {
|
||||
os.Exit(exit.Code)
|
||||
}
|
||||
panic(e)
|
||||
}
|
||||
}
|
||||
|
||||
func generatePageHtml(w http.ResponseWriter, paths []string) error {
|
||||
fileList, err := getFileList(paths)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue