Readded missing exit-handling function

This commit is contained in:
Seednode 2022-09-08 16:05:07 -05:00
parent 731f1a6791
commit c61eeb004a
2 changed files with 13 additions and 3 deletions

View File

@ -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)
}
}

View File

@ -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 {