Skip to content

Commit

Permalink
fix: transaction log on bad query
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Mar 26, 2024
1 parent fff6b62 commit 56f64ea
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/api/rest/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,6 @@ func handlerGetTransactionAddress(c *fiber.Ctx) error {

params := new(TransactionsQuery)
if err := c.QueryParser(params); err != nil {
zap.S().Warnf("Transactions Get Handler ERROR: %s", err.Error())

c.Status(422)
return c.SendString(`{"error": "could not parse query parameters"}`)
}
Expand All @@ -452,17 +450,20 @@ func handlerGetTransactionAddress(c *fiber.Ctx) error {
}

transactions, err := crud.GetTransactionCrud().SelectManyByAddress(
params.Limit,
params.Skip,
address,
params.Limit, params.Skip, address,
)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
c.Status(404)
return c.SendString(`{"error": "no transactions found"}`)
}
c.Status(500)
zap.S().Warn(
"Endpoint=handlerGetTransactionAddress",
" Error=Could not retrieve transactions: ", err.Error(),
" Error=Could not retrieve transactions: ",
err.Error(),
)
return c.SendString(`{"error": "no transactions found"}`)
return c.SendString(`{"error": "could not retrieve transactions"}`)
}

// X-TOTAL-COUNT
Expand Down

0 comments on commit 56f64ea

Please sign in to comment.