Fix redundant echo/http error wrapping.

This commit is contained in:
Kailash Nadh 2022-07-02 16:07:29 +05:30
parent 4a6e041ca8
commit 68da86aadc
2 changed files with 7 additions and 4 deletions

View file

@ -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,

View file

@ -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.