Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit b259203

Browse files
committed
Return 404 if output is not found
1 parent 4317d0e commit b259203

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

pkg/requesthandler/transaction.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/labstack/echo/v4"
55

66
"github.com/iotaledger/hive.go/ierrors"
7+
"github.com/iotaledger/hive.go/kvstore"
78

89
"github.com/iotaledger/iota-core/pkg/retainer/txretainer"
910
iotago "github.com/iotaledger/iota.go/v4"
@@ -16,6 +17,10 @@ func (r *RequestHandler) BlockIDFromTransactionID(transactionID iotago.Transacti
1617

1718
output, spent, err := r.protocol.Engines.Main.Get().Ledger.OutputOrSpent(outputID)
1819
if err != nil {
20+
if ierrors.Is(err, kvstore.ErrKeyNotFound) {
21+
return iotago.EmptyBlockID, ierrors.WithMessagef(echo.ErrNotFound, "output %s not found", outputID.ToHex())
22+
}
23+
1924
return iotago.EmptyBlockID, ierrors.WithMessagef(echo.ErrInternalServerError, "failed to get output %s: %w", outputID.ToHex(), err)
2025
}
2126

0 commit comments

Comments
 (0)