diff options
Diffstat (limited to 'pkg/handler')
-rw-r--r-- | pkg/handler/error.go | 14 | ||||
-rw-r--r-- | pkg/handler/quote.go | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/pkg/handler/error.go b/pkg/handler/error.go new file mode 100644 index 0000000..f74be59 --- /dev/null +++ b/pkg/handler/error.go @@ -0,0 +1,14 @@ +package handler + +import ( + "log" + + "github.com/labstack/echo/v4" + "sh.org.ru/pkg/tpl" +) + +func ErrorHandler(err error, c echo.Context) { + if err := tpl.ErrorPage(err.Error()).Render(c.Request().Context(), c.Response()); err != nil { + log.Println(err) + } +} diff --git a/pkg/handler/quote.go b/pkg/handler/quote.go index af9fd82..2a5f7e6 100644 --- a/pkg/handler/quote.go +++ b/pkg/handler/quote.go @@ -12,7 +12,7 @@ func (h *Handler) Quote(c echo.Context) error { sid := c.Param("id") id, err := strconv.Atoi(sid) if err != nil { - return err + return echo.ErrNotFound } quote := new(model.Quote) |