Let error handler handle all error logic, logging, and canceling.

This commit is contained in:
mikestefanello 2022-05-17 08:45:18 -04:00
parent 31a3503021
commit ecd0120920
10 changed files with 43 additions and 49 deletions

View file

@ -41,11 +41,11 @@ func (c *contact) Post(ctx echo.Context) error {
// Parse the form values
if err := ctx.Bind(&form); err != nil {
return c.Fail(ctx, err, "unable to bind form")
return c.Fail(err, "unable to bind form")
}
if err := form.Submission.Process(ctx, form); err != nil {
return c.Fail(ctx, err, "unable to process form submission")
return c.Fail(err, "unable to process form submission")
}
if !form.Submission.HasErrors() {
@ -57,7 +57,7 @@ func (c *contact) Post(ctx echo.Context) error {
Send(ctx)
if err != nil {
return c.Fail(ctx, err, "unable to send email")
return c.Fail(err, "unable to send email")
}
}