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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -26,8 +26,7 @@ var rootCmd = &cobra.Command{
|
||||||
func Execute() {
|
func Execute() {
|
||||||
err := rootCmd.Execute()
|
err := rootCmd.Execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
log.Fatal(err)
|
||||||
panic(Exit{1})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
cmd/web.go
11
cmd/web.go
|
@ -16,6 +16,17 @@ import (
|
||||||
"strings"
|
"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 {
|
func generatePageHtml(w http.ResponseWriter, paths []string) error {
|
||||||
fileList, err := getFileList(paths)
|
fileList, err := getFileList(paths)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue