diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-08 00:01:44 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-08 00:01:44 +0200 |
commit | 6079b1d963f34ada5c4b25363f2319901e283936 (patch) | |
tree | f7f93616eb3dacfcebee486fe7542ec3adfb3950 /pkg/handler/about | |
parent | e9098e00fb6339b759df5b0df2e086cef8a7ce83 (diff) | |
download | cerrado-6079b1d963f34ada5c4b25363f2319901e283936.tar.gz cerrado-6079b1d963f34ada5c4b25363f2319901e283936.tar.bz2 cerrado-6079b1d963f34ada5c4b25363f2319901e283936.zip |
feat: Add error handling
Diffstat (limited to 'pkg/handler/about')
-rw-r--r-- | pkg/handler/about/handler.go | 10 |
1 files changed, 4 insertions, 6 deletions
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 } |