Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix redundant echo/http error wrapping.

Kailash Nadh68da86aadcfb
diff --git a/cmd/templates.go b/cmd/templates.go
index bed1690f..4f2c065e 100644
--- a/cmd/templates.go
+++ b/cmd/templates.go
@@ -126,7 +126,7 @@ func handleCreateTemplate(c echo.Context) error {
}
if err := validateTemplate(o, app); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, err.Error())
+ return err
}
// Subject is only relevant for fixed tx templates. For campaigns,
@@ -172,7 +172,7 @@ func handleUpdateTemplate(c echo.Context) error {
}
if err := validateTemplate(o, app); err != nil {
- return echo.NewHTTPError(http.StatusBadRequest, err.Error())
+ return err
}
// Subject is only relevant for fixed tx templates. For campaigns,
diff --git a/cmd/tx.go b/cmd/tx.go
index 5855a042..893fb419 100644
--- a/cmd/tx.go
+++ b/cmd/tx.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"net/http"
"net/textproto"
@@ -30,7 +31,8 @@ func handleSendTxMessage(c echo.Context) error {
// Get the cached tx template.
tpl, err := app.manager.GetTpl(m.TemplateID)
if err != nil {
- return err
+ return echo.NewHTTPError(http.StatusBadRequest,
+ app.i18n.Ts("globals.messages.notFound", "name", fmt.Sprintf("template %d", m.TemplateID)))
}
// Get the subscriber.
@@ -41,7 +43,8 @@ func handleSendTxMessage(c echo.Context) error {
// Render the message.
if err := m.Render(sub, tpl); err != nil {
- return err
+ return echo.NewHTTPError(http.StatusBadRequest,
+ app.i18n.Ts("globals.messages.errorFetching", "name"))
}
// Prepare the final message.