~arcade/hcwiki-devel

Add an error message for every error v2 APPLIED

Scott Little: 1
 Add an error message for every error

 1 files changed, 10 insertions(+), 11 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~arcade/hcwiki-devel/patches/25258/mbox | git am -3
Learn more about email & git

[PATCH v2] Add an error message for every error Export this patch

diff --git a/hcwiki.go b/hcwiki.go
index fe47589..8a4d69f 100644
--- a/hcwiki.go
+++ b/hcwiki.go
@@ -7,7 +7,6 @@ import (
	"log"
	"net/url"
	"os"
        "log"
	"os/exec"
	"path"
	"strings"
@@ -35,7 +34,7 @@ type frontMatter struct {
func validateLink(link string, conf config) string {
	linkURL, err := url.Parse(link)
	if err != nil {
		panic(err)
		log.Fatalf("%v: cannot parse link (%v)", link, err)
	}
	if linkURL.Scheme != "" {
		return conf.InvalidPage
@@ -51,7 +50,7 @@ func parseGmi(filename string, conf config) map[string]interface{} {
	source := conf.PathToSource + "/" + filename
	file, err := os.Open(source)
	if err != nil {
		panic(err)
		log.Fatalf("%v: no such file or directory (%v)", source, err)
	}

	matter := front.NewMatter()
@@ -59,7 +58,7 @@ func parseGmi(filename string, conf config) map[string]interface{} {
	fmatter, body, err := matter.Parse(file)
	if err != nil {
		fmt.Fprintln(os.Stderr, chalk.Red, "Uh oh looks like there's no front matter.")
		panic(err)
		log.Fatalf("%v: cannot parse front matter (%v)", source, err)
	}

	newFilename := strings.Replace(filename, path.Ext(filename), ".gmi", 1) // dark magic that could break at any time 🎵
@@ -69,7 +68,7 @@ func parseGmi(filename string, conf config) map[string]interface{} {

	page, err := gemtext.ParsePage(body)
	if err != nil {
		panic(err)
		log.Fatalf("%v: invalid gemtext (%v)", source, err)
	}

	for i, item := range page {
@@ -133,7 +132,7 @@ func loadTags(conf config) map[string]interface{} {

	rawJSON, err := os.ReadFile(conf.TagFile)
	if err != nil {
		log.Fatalf("Cannot open %v: %v", conf.TagFile, err)
		log.Fatalf("%v: no such file or directory (%v)", conf.TagFile, err)
	}

	json.Unmarshal(rawJSON, &tags)
@@ -146,7 +145,7 @@ func buildFiles(conf config) map[string]interface{} {

	files, err := ioutil.ReadDir(conf.PathToSource)
	if err != nil {
		panic(err)
		log.Fatalf("%v: not a directory (%v)", conf.PathToSource, err)
	}

	for _, file := range files {
@@ -168,11 +167,11 @@ func main() {
	var conf config
	tomlData, err := os.ReadFile("config.toml")
	if err != nil {
		panic(err)
		log.Fatalf("Cannot open file 'config.toml': %v", err)
	}

	if _, err := toml.Decode(string(tomlData), &conf); err != nil {
		panic(err)
 	if _, err := toml.Decode(string(tomlData), &conf); err != nil {
		log.Fatalf("Cannot decode 'config.toml:  %v", err)
	}

	usage := `hcwiki - the hack club tilde wiki
@@ -228,7 +227,7 @@ Usage:
	} else if arguments["list"] == true {
		files, err := ioutil.ReadDir(conf.PathToSource)
		if err != nil {
			panic(err)
			log.Fatalf("Cannot open %v: no such fiile or directory", conf.PathToSource)
		}

		for _, file := range files {
-- 
2.33.0