Fix redundant echo/http error wrapping.
This commit is contained in:
parent
4a6e041ca8
commit
68da86aadc
2 changed files with 7 additions and 4 deletions
|
@ -126,7 +126,7 @@ func handleCreateTemplate(c echo.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateTemplate(o, app); err != nil {
|
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,
|
// 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 {
|
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,
|
// Subject is only relevant for fixed tx templates. For campaigns,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
|
|
||||||
|
@ -30,7 +31,8 @@ func handleSendTxMessage(c echo.Context) error {
|
||||||
// Get the cached tx template.
|
// Get the cached tx template.
|
||||||
tpl, err := app.manager.GetTpl(m.TemplateID)
|
tpl, err := app.manager.GetTpl(m.TemplateID)
|
||||||
if err != nil {
|
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.
|
// Get the subscriber.
|
||||||
|
@ -41,7 +43,8 @@ func handleSendTxMessage(c echo.Context) error {
|
||||||
|
|
||||||
// Render the message.
|
// Render the message.
|
||||||
if err := m.Render(sub, tpl); err != nil {
|
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.
|
// Prepare the final message.
|
||||||
|
|
Loading…
Reference in a new issue