diff options
Diffstat (limited to 'echo/error_handler.go')
-rw-r--r-- | echo/error_handler.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/echo/error_handler.go b/echo/error_handler.go index c32fe86..bfbcfb6 100644 --- a/echo/error_handler.go +++ b/echo/error_handler.go | |||
@@ -4,14 +4,14 @@ import ( | |||
4 | "bytes" | 4 | "bytes" |
5 | "fmt" | 5 | "fmt" |
6 | "html/template" | 6 | "html/template" |
7 | "io/fs" | ||
7 | "net/http" | 8 | "net/http" |
8 | "path" | ||
9 | 9 | ||
10 | "github.com/labstack/echo/v4" | 10 | "github.com/labstack/echo/v4" |
11 | ) | 11 | ) |
12 | 12 | ||
13 | // Copied from echo and tweaked to make our errors nicer | 13 | // Copied from echo and tweaked to make our errors nicer |
14 | func ErrorHandler(templatePath string, funcs template.FuncMap) func(error, echo.Context) { | 14 | func ErrorHandler(templates fs.FS, funcs template.FuncMap) func(error, echo.Context) { |
15 | return func(err error, c echo.Context) { | 15 | return func(err error, c echo.Context) { |
16 | defer func() { | 16 | defer func() { |
17 | if r := recover(); r != nil { | 17 | if r := recover(); r != nil { |
@@ -37,12 +37,13 @@ func ErrorHandler(templatePath string, funcs template.FuncMap) func(error, echo. | |||
37 | } | 37 | } |
38 | } | 38 | } |
39 | 39 | ||
40 | t, err := template.New("").Funcs(funcs).ParseFiles( | 40 | t, err := template.New("").Funcs(funcs).ParseFS( |
41 | path.Join(templatePath, "404.tpl"), | 41 | templates, |
42 | path.Join(templatePath, "40x.tpl"), | 42 | "404.tpl", |
43 | path.Join(templatePath, "50x.tpl"), | 43 | "40x.tpl", |
44 | path.Join(templatePath, "header.tpl"), | 44 | "50x.tpl", |
45 | path.Join(templatePath, "footer.tpl"), | 45 | "header.tpl", |
46 | "footer.tpl", | ||
46 | ) | 47 | ) |
47 | if err != nil { | 48 | if err != nil { |
48 | he = &echo.HTTPError{ | 49 | he = &echo.HTTPError{ |