Skip to content

Commit

Permalink
Remove other unknown type errors and panic instead
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGackstatter committed Mar 11, 2024
1 parent 4d576df commit 09676f0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion builder/transaction_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (b *TransactionBuilder) getStoredManaOutputAccountID(storedManaOutputIndex
}

default:
return iotago.EmptyAccountID, ierrors.WithMessagef(iotago.ErrUnknownOutputType, "output type %T does not support stored mana", output)
return iotago.EmptyAccountID, ierrors.Errorf("output type %s does not support stored mana", output.Type())
}

return storedManaOutputAccountID, nil
Expand Down
2 changes: 0 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ var (
var (
// ErrUTXOInputInvalid gets returned when the UTXO input is invalid.
ErrUTXOInputInvalid = ierrors.New("UTXO input is invalid")
// ErrUnknownOutputType gets returned for unknown output types.
ErrUnknownOutputType = ierrors.New("unknown output type")
// ErrCommitmentInputMissing gets returned when the commitment has not been provided when needed.
ErrCommitmentInputMissing = ierrors.New("commitment input required with reward or BIC input")
// ErrCommitmentInputReferenceInvalid gets returned when the commitment input references an invalid commitment.
Expand Down
2 changes: 0 additions & 2 deletions signed_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ var (
ErrInputOutputBaseTokenMismatch = ierrors.New("inputs and outputs do not spend/deposit the same amount of base tokens")
// ErrManaOverflow gets returned when there is an under- or overflow in Mana calculations.
ErrManaOverflow = ierrors.New("under- or overflow in Mana calculations")
// ErrUnknownSignatureType gets returned for unknown signature types.
ErrUnknownSignatureType = ierrors.New("unknown signature type")
// ErrInputUnlockCountMismatch gets returned when the unlock count and input count mismatch.
ErrInputUnlockCountMismatch = ierrors.New("unlock count and input count mismatch")
// ErrSignatureAndAddrIncompatible gets returned if an address of an input has a companion signature unlock with the wrong signature type.
Expand Down
3 changes: 1 addition & 2 deletions tpkg/rand_unlock.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tpkg

import (
"github.com/iotaledger/hive.go/ierrors"
iotago "github.com/iotaledger/iota.go/v4"
)

Expand Down Expand Up @@ -30,7 +29,7 @@ func RandUnlock(allowEmptyUnlock bool) iotago.Unlock {
case iotago.UnlockEmpty:
return &iotago.EmptyUnlock{}
default:
panic(ierrors.Wrapf(iotago.ErrUnknownUnlockType, "type %d", unlockType))
panic("all known unlock types should be handled above")
}
}

Expand Down
6 changes: 2 additions & 4 deletions unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ var (
ErrReferentialUnlockInvalid = ierrors.New("invalid referential unlock")
// ErrSignatureUnlockHasNilSignature gets returned if a signature unlock contains a nil signature.
ErrSignatureUnlockHasNilSignature = ierrors.New("signature is nil")
// ErrUnknownUnlockType gets returned for unknown unlock.
ErrUnknownUnlockType = ierrors.New("unknown unlock type")
// ErrNestedMultiUnlock gets returned when a MultiUnlock is nested inside a MultiUnlock.
ErrNestedMultiUnlock = ierrors.New("multi unlocks can't be nested")
// ErrEmptyUnlockOutsideMultiUnlock gets returned when an empty unlock was not nested inside of a multi unlock.
Expand Down Expand Up @@ -252,7 +250,7 @@ func SignaturesUniqueAndReferenceUnlocksValidator(api API) UnlockValidatorFunc {
continue

default:
return ierrors.WithMessagef(ErrUnknownUnlockType, "unlock at index %d.%d is of unknown type %T", index, subIndex, subUnlock)
panic("all known unlock types should be handled above")
}
}
seenMultiUnlocks[uint16(index)] = struct{}{}
Expand All @@ -262,7 +260,7 @@ func SignaturesUniqueAndReferenceUnlocksValidator(api API) UnlockValidatorFunc {
return ierrors.WithMessagef(ErrEmptyUnlockOutsideMultiUnlock, "unlock at index %d is invalid", index)

default:
return ierrors.WithMessagef(ErrUnknownUnlockType, "unlock at index %d is of unknown type %T", index, unlock)
panic("all known unlock types should be handled above")
}

return nil
Expand Down

0 comments on commit 09676f0

Please sign in to comment.