Wrap some errors
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Jan Bader 2022-08-21 19:56:55 +00:00
parent 4ef0b759ef
commit 2f636b5f9c
3 changed files with 12 additions and 9 deletions

View File

@ -29,6 +29,8 @@ linters-settings:
wrapcheck:
ignoreSigs:
- .JSON(
- .Redirect(
- .String(
- .Errorf(
- errors.New(
- errors.Unwrap(

View File

@ -63,7 +63,7 @@ func (h *Handler) loginPost(c echo.Context) error {
var login loginInformation
err := c.Bind(&login)
if err != nil {
return err
return fmt.Errorf("parse payload: %w", err)
}
user, err := h.Service.GetUserByUsername(c.Request().Context(), login.User)
@ -72,12 +72,12 @@ func (h *Handler) loginPost(c echo.Context) error {
}
if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
return err
return fmt.Errorf("verify password: %w", err)
}
token, err := h.TokenVerifier.CreateToken(&user)
if err != nil {
return err
return fmt.Errorf("create token: %w", err)
}
go h.UpdateLastLogin(user.ID)
@ -120,7 +120,7 @@ func (h *Handler) registerPost(c echo.Context) error {
hash, err := h.CredentialsVerifier.Hash(register.Password)
if err != nil {
return err
return fmt.Errorf("hash password: %w", err)
}
createUser := postgres.CreateUserParams{
@ -135,7 +135,7 @@ func (h *Handler) registerPost(c echo.Context) error {
token, err := h.TokenVerifier.CreateToken(&user)
if err != nil {
return err
return fmt.Errorf("create token: %w", err)
}
go h.UpdateLastLogin(user.ID)

View File

@ -1,6 +1,7 @@
package server
import (
"fmt"
"net/http"
"git.javil.eu/jacob1123/budgeteer/postgres"
@ -26,12 +27,12 @@ func (h *Handler) importYNAB(c echo.Context) error {
transactionsFile, err := c.FormFile("transactions")
if err != nil {
return err
return fmt.Errorf("get transactions: %w", err)
}
transactions, err := transactionsFile.Open()
if err != nil {
return err
return fmt.Errorf("open transactions: %w", err)
}
err = ynab.ImportTransactions(c.Request().Context(), transactions)
@ -41,12 +42,12 @@ func (h *Handler) importYNAB(c echo.Context) error {
assignmentsFile, err := c.FormFile("assignments")
if err != nil {
return err
return fmt.Errorf("get assignments: %w", err)
}
assignments, err := assignmentsFile.Open()
if err != nil {
return err
return fmt.Errorf("open assignments: %w", err)
}
err = ynab.ImportAssignments(c.Request().Context(), assignments)