From b259203d47e6b0202dcfefb51d34de23d02485b1 Mon Sep 17 00:00:00 2001 From: muXxer Date: Fri, 22 Mar 2024 17:12:44 +0100 Subject: [PATCH] Return 404 if output is not found --- pkg/requesthandler/transaction.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/requesthandler/transaction.go b/pkg/requesthandler/transaction.go index 8e26961d2..c5d4f8481 100644 --- a/pkg/requesthandler/transaction.go +++ b/pkg/requesthandler/transaction.go @@ -4,6 +4,7 @@ import ( "github.com/labstack/echo/v4" "github.com/iotaledger/hive.go/ierrors" + "github.com/iotaledger/hive.go/kvstore" "github.com/iotaledger/iota-core/pkg/retainer/txretainer" iotago "github.com/iotaledger/iota.go/v4" @@ -16,6 +17,10 @@ func (r *RequestHandler) BlockIDFromTransactionID(transactionID iotago.Transacti output, spent, err := r.protocol.Engines.Main.Get().Ledger.OutputOrSpent(outputID) if err != nil { + if ierrors.Is(err, kvstore.ErrKeyNotFound) { + return iotago.EmptyBlockID, ierrors.WithMessagef(echo.ErrNotFound, "output %s not found", outputID.ToHex()) + } + return iotago.EmptyBlockID, ierrors.WithMessagef(echo.ErrInternalServerError, "failed to get output %s: %w", outputID.ToHex(), err) }