Skip to content

Commit

Permalink
Return 404 if output is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Mar 22, 2024
1 parent 4317d0e commit b259203
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/requesthandler/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}

Expand Down

0 comments on commit b259203

Please sign in to comment.