Skip to content

Commit 17099af

Browse files
committed
[FAB-2971] Improve invalid cc name/version error msg
This change updates the error messages for invalid chaincode name and version to include the rules that define valid characters. Change-Id: I9cc63131a1271a867e6d99e52a822b2c3319e6f8 Signed-off-by: Will Lahti <[email protected]>
1 parent c6df437 commit 17099af

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/scc/lccc/lccc.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,21 @@ func (t TXNotFoundErr) Error() string {
135135
type InvalidDeploymentSpecErr string
136136

137137
func (f InvalidDeploymentSpecErr) Error() string {
138-
return fmt.Sprintf("Invalid deployment spec : %s", string(f))
138+
return fmt.Sprintf("invalid deployment spec : %s", string(f))
139139
}
140140

141141
//ExistsErr chaincode exists error
142142
type ExistsErr string
143143

144144
func (t ExistsErr) Error() string {
145-
return fmt.Sprintf("Chaincode exists %s", string(t))
145+
return fmt.Sprintf("chaincode exists %s", string(t))
146146
}
147147

148148
//NotFoundErr chaincode not registered with LCCC error
149149
type NotFoundErr string
150150

151151
func (t NotFoundErr) Error() string {
152-
return fmt.Sprintf("chaincode not found %s", string(t))
152+
return fmt.Sprintf("could not find chaincode with name '%s'", string(t))
153153
}
154154

155155
//InvalidChainNameErr invalid chain name error
@@ -163,7 +163,7 @@ func (f InvalidChainNameErr) Error() string {
163163
type InvalidChaincodeNameErr string
164164

165165
func (f InvalidChaincodeNameErr) Error() string {
166-
return fmt.Sprintf("invalid chaincode name %s", string(f))
166+
return fmt.Sprintf("invalid chaincode name '%s'. Names can only consist of alphanumerics, '_', and '-'", string(f))
167167
}
168168

169169
//EmptyChaincodeNameErr trying to upgrade to same version of Chaincode
@@ -177,14 +177,14 @@ func (f EmptyChaincodeNameErr) Error() string {
177177
type InvalidVersionErr string
178178

179179
func (f InvalidVersionErr) Error() string {
180-
return fmt.Sprintf("invalid chaincode version %s", string(f))
180+
return fmt.Sprintf("invalid chaincode version '%s'. Versions can only consist of alphanumerics, '_', '-', and '.'", string(f))
181181
}
182182

183183
//EmptyVersionErr empty version error
184184
type EmptyVersionErr string
185185

186186
func (f EmptyVersionErr) Error() string {
187-
return fmt.Sprintf("version not provided for chaincode %s", string(f))
187+
return fmt.Sprintf("version not provided for chaincode with name '%s'", string(f))
188188
}
189189

190190
//MarshallErr error marshaling/unmarshalling
@@ -198,7 +198,7 @@ func (m MarshallErr) Error() string {
198198
type IdenticalVersionErr string
199199

200200
func (f IdenticalVersionErr) Error() string {
201-
return fmt.Sprintf("chaincode with the same version exists %s", string(f))
201+
return fmt.Sprintf("version already exists for chaincode with name '%s'", string(f))
202202
}
203203

204204
//-------------- helper functions ------------------

0 commit comments

Comments
 (0)