diff --git a/internal/api/impl.go b/internal/api/impl.go index a8cc21c..c379160 100644 --- a/internal/api/impl.go +++ b/internal/api/impl.go @@ -21,7 +21,7 @@ func (server *ServerImpl) GetBanks(ctx echo.Context) error { banks, err := server.Dal.Banks() if err != nil { - return ctx.NoContent(http.StatusInternalServerError) + return err } if len(banks) == 0 { @@ -36,8 +36,7 @@ func (server *ServerImpl) GetBankById(ctx echo.Context, bankId string) error { bank, err := server.Dal.Bank(bankId) if err != nil { - log.Printf("%v", err) - return ctx.NoContent(http.StatusInternalServerError) + return err } if bank == nil { @@ -78,8 +77,7 @@ func (server *ServerImpl) GetTransactionById(ctx echo.Context, transactionId int transaction, err := server.Dal.Transaction(transactionId) if err != nil { - log.Printf("%v", err) - return ctx.NoContent(http.StatusInternalServerError) + return err } if transaction == nil { @@ -98,8 +96,7 @@ func (server *ServerImpl) CreateTransaction(ctx echo.Context) error { transaction, err := server.Dal.InsertTransaction(transaction2entity(*t)) if err != nil { - log.Printf("%v", err) - return ctx.NoContent(http.StatusInternalServerError) + return err } return ctx.JSON(http.StatusCreated, entity2transaction(transaction)) @@ -107,8 +104,7 @@ func (server *ServerImpl) CreateTransaction(ctx echo.Context) error { func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int64) error { if exists, err := server.Dal.TransactionExists(entity.TransactionId(transactionId)); err != nil { - log.Printf("%v", err) - return ctx.NoContent(http.StatusInternalServerError) + return err } else if !exists { return ctx.NoContent(http.StatusNotFound) } @@ -121,8 +117,7 @@ func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int6 success, err := server.Dal.UpdateTransaction(entity.TransactionId(transactionId), update.Category) if err != nil { - log.Printf("%v", err) - return ctx.NoContent(http.StatusInternalServerError) + return err } if !success { @@ -134,7 +129,7 @@ func (server *ServerImpl) UpdateTransaction(ctx echo.Context, transactionId int6 func (server *ServerImpl) GetCategories(ctx echo.Context) error { categories, err := server.Dal.Categories() if err != nil { - return ctx.NoContent(http.StatusInternalServerError) + return err } if len(categories) == 0 {