From b45a4162b435485801e0a74b5600466b1fdaeac1 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 20 Sep 2021 17:23:19 +0300 Subject: [PATCH] [#121] container: Reword panic messages for better error wrapping Signed-off-by: Alex Vanin --- container/container_contract.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/container/container_contract.go b/container/container_contract.go index 73eb15a..7e78415 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -80,7 +80,7 @@ func _deploy(data interface{}, isUpdate bool) { } if len(addrNetmap) != 20 || len(addrBalance) != 20 || len(addrID) != 20 { - panic("init: incorrect length of contract script hash") + panic("incorrect length of contract script hash") } storage.Put(ctx, common.OwnerKey, owner) @@ -305,7 +305,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK ownerID := getOwnerByID(ctx, containerID) if len(ownerID) == 0 { - panic("setEACL: container does not exists") + panic("container does not exist") } var ( // for invocation collection without notary @@ -362,7 +362,7 @@ func EACL(containerID []byte) ExtendedACL { ownerID := getOwnerByID(ctx, containerID) if len(ownerID) == 0 { - panic("eACL: container does not exists") + panic("container does not exist") } return getEACL(ctx, containerID) @@ -375,11 +375,11 @@ func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.Public ctx := storage.GetContext() if !runtime.CheckWitness(pubKey) { - panic("container: invalid witness for size estimation") + panic("invalid witness of container size estimation") } if !isStorageNode(ctx, pubKey) { - panic("container: only storage nodes can save size estimations") + panic("putContainerSize method must be invoked by storage node from network map") } key := estimationKey(epoch, cid, pubKey) @@ -457,12 +457,12 @@ func NewEpoch(epochNum int) { netmapContractKey, ) if !indirectCall { - panic("newEpoch: this method must be invoked from inner ring") + panic("newEpoch method must be invoked by inner ring") } } else { multiaddr := common.AlphabetAddress() if !runtime.CheckWitness(multiaddr) { - panic("newEpoch: this method must be invoked from inner ring") + panic("newEpoch method must be invoked by inner ring") } } @@ -487,12 +487,12 @@ func StartContainerEstimation(epoch int) { alphabet = common.AlphabetNodes() nodeKey = common.InnerRingInvoker(alphabet) if len(nodeKey) == 0 { - panic("startEstimation: only inner ring nodes can invoke this") + panic("startContainerEstimation method must be invoked by inner ring") } } else { multiaddr := common.AlphabetAddress() if !runtime.CheckWitness(multiaddr) { - panic("startEstimation: only inner ring nodes can invoke this") + panic("startContainerEstimation method must be invoked by inner ring") } } @@ -527,12 +527,12 @@ func StopContainerEstimation(epoch int) { alphabet = common.AlphabetNodes() nodeKey = common.InnerRingInvoker(alphabet) if len(nodeKey) == 0 { - panic("stopEstimation: only inner ring nodes can invoke this") + panic("stopContainerEstimation method must be invoked by inner ring") } } else { multiaddr := common.AlphabetAddress() if !runtime.CheckWitness(multiaddr) { - panic("stopEstimation: only inner ring nodes can invoke this") + panic("stopContainerEstimation method must be invoked by inner ring") } }