@@ -17,6 +17,7 @@ limitations under the License.
17
17
package ccprovider
18
18
19
19
import (
20
+ "errors"
20
21
"fmt"
21
22
"os"
22
23
@@ -180,15 +181,15 @@ func (ccpack *SignedCDSPackage) getCDSData(scds *pb.SignedChaincodeDeploymentSpe
180
181
// ChaincodeDeploymentSpec
181
182
func (ccpack * SignedCDSPackage ) ValidateCC (ccdata * ChaincodeData ) error {
182
183
if ccpack .sDepSpec == nil {
183
- return fmt . Errorf ("uninitialized package" )
184
+ return errors . New ("uninitialized package" )
184
185
}
185
186
186
187
if ccpack .sDepSpec .ChaincodeDeploymentSpec == nil {
187
- return fmt . Errorf ("signed chaincode deployment spec cannot be nil in a package" )
188
+ return errors . New ("signed chaincode deployment spec cannot be nil in a package" )
188
189
}
189
190
190
191
if ccpack .depSpec == nil {
191
- return fmt . Errorf ("chaincode deployment spec cannot be nil in a package" )
192
+ return errors . New ("chaincode deployment spec cannot be nil in a package" )
192
193
}
193
194
194
195
// This is a hack. LSCC expects a specific LSCC error when names are invalid so it
@@ -212,7 +213,7 @@ func (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error {
212
213
}
213
214
214
215
if ! proto .Equal (ccpack .data , otherdata ) {
215
- return fmt . Errorf ("data mismatch" )
216
+ return errors . New ("data mismatch" )
216
217
}
217
218
218
219
return nil
@@ -223,21 +224,21 @@ func (ccpack *SignedCDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, erro
223
224
env := & common.Envelope {}
224
225
err := proto .Unmarshal (buf , env )
225
226
if err != nil {
226
- return nil , fmt . Errorf ("failed to unmarshal envelope from bytes" )
227
+ return nil , errors . New ("failed to unmarshal envelope from bytes" )
227
228
}
228
229
cHdr , sDepSpec , err := ccpackage .ExtractSignedCCDepSpec (env )
229
230
if err != nil {
230
231
return nil , err
231
232
}
232
233
233
234
if cHdr .Type != int32 (common .HeaderType_CHAINCODE_PACKAGE ) {
234
- return nil , fmt . Errorf ("invalid type of envelope for chaincode package" )
235
+ return nil , errors . New ("invalid type of envelope for chaincode package" )
235
236
}
236
237
237
238
depSpec := & pb.ChaincodeDeploymentSpec {}
238
239
err = proto .Unmarshal (sDepSpec .ChaincodeDeploymentSpec , depSpec )
239
240
if err != nil {
240
- return nil , fmt . Errorf ("error getting deployment spec" )
241
+ return nil , errors . New ("error getting deployment spec" )
241
242
}
242
243
243
244
databytes , id , data , err := ccpack .getCDSData (sDepSpec )
@@ -278,27 +279,27 @@ func (ccpack *SignedCDSPackage) InitFromPath(ccNameVersion string, path string)
278
279
// PutChaincodeToFS - serializes chaincode to a package on the file system
279
280
func (ccpack * SignedCDSPackage ) PutChaincodeToFS () error {
280
281
if ccpack .buf == nil {
281
- return fmt . Errorf ("uninitialized package" )
282
+ return errors . New ("uninitialized package" )
282
283
}
283
284
284
285
if ccpack .id == nil {
285
- return fmt . Errorf ("id cannot be nil if buf is not nil" )
286
+ return errors . New ("id cannot be nil if buf is not nil" )
286
287
}
287
288
288
289
if ccpack .sDepSpec == nil || ccpack .depSpec == nil {
289
- return fmt . Errorf ("depspec cannot be nil if buf is not nil" )
290
+ return errors . New ("depspec cannot be nil if buf is not nil" )
290
291
}
291
292
292
293
if ccpack .env == nil {
293
- return fmt . Errorf ("env cannot be nil if buf and depspec are not nil" )
294
+ return errors . New ("env cannot be nil if buf and depspec are not nil" )
294
295
}
295
296
296
297
if ccpack .data == nil {
297
- return fmt . Errorf ("nil data" )
298
+ return errors . New ("nil data" )
298
299
}
299
300
300
301
if ccpack .datab == nil {
301
- return fmt . Errorf ("nil data bytes" )
302
+ return errors . New ("nil data bytes" )
302
303
}
303
304
304
305
ccname := ccpack .depSpec .ChaincodeSpec .ChaincodeId .Name
0 commit comments