From cb5b841b1c306e10ee31e59ed28883576ab839d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=ADghearn=C3=A1n=20Carroll?= Date: Thu, 30 Sep 2021 15:07:15 +0100 Subject: [PATCH] fixed raw sql error, not 404s (#50) --- data/sqlite/transaction.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/sqlite/transaction.go b/data/sqlite/transaction.go index 96de5823..d602a485 100644 --- a/data/sqlite/transaction.go +++ b/data/sqlite/transaction.go @@ -161,11 +161,15 @@ func (s *sqliteStore) TransactionUpdateState(ctx context.Context, args payd.Tran "failed to commit transaction when updating transactionId '%s' state to '%s'", args.TxID, req.State) } +// Tx returns a tx from the internal store. func (s *sqliteStore) Tx(ctx context.Context, txID string) (*bt.Tx, error) { var txhex struct { TxHex string `db:"tx_hex"` } if err := s.db.GetContext(ctx, &txhex, sqlTransactionGet, txID); err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, lathos.NewErrNotFound("T001", fmt.Sprintf("tx '%s' not in store", txID)) + } return nil, errors.Wrapf(err, "failed to retrieve transaction for id %s", txID) }