From 6079b1d963f34ada5c4b25363f2319901e283936 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 8 Jun 2024 00:01:44 +0200 Subject: feat: Add error handling --- pkg/handler/about/handler.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'pkg/handler/about/handler.go') diff --git a/pkg/handler/about/handler.go b/pkg/handler/about/handler.go index 1acde60..ac3d314 100644 --- a/pkg/handler/about/handler.go +++ b/pkg/handler/about/handler.go @@ -2,7 +2,6 @@ package about import ( "io" - "log/slog" "net/http" "os" @@ -27,17 +26,15 @@ func NewAboutHandler(configRepo configurationRepository) *AboutHandler { return &AboutHandler{configRepo.GetRootReadme()} } -func (g *AboutHandler) About(w http.ResponseWriter, _ *http.Request) { +func (g *AboutHandler) About(w http.ResponseWriter, _ *http.Request) error { f, err := os.Open(g.readmePath) if err != nil { - slog.Error("Error loading readme file", "error", err) - return + return err } bs, err := io.ReadAll(f) if err != nil { - slog.Error("Error reading readme file bytes", "error", err) - return + return err } extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock @@ -54,4 +51,5 @@ func (g *AboutHandler) About(w http.ResponseWriter, _ *http.Request) { Body: bs, } templates.WritePageTemplate(w, gitList) + return nil } -- cgit v1.2.3