github.com/binyushen/fabric@v2.1.1+incompatible/core/scc/lscc/errors.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package lscc
     8  
     9  import "fmt"
    10  
    11  //InvalidFunctionErr invalid function error
    12  type InvalidFunctionErr string
    13  
    14  func (f InvalidFunctionErr) Error() string {
    15  	return fmt.Sprintf("invalid function to lscc: %s", string(f))
    16  }
    17  
    18  //InvalidArgsLenErr invalid arguments length error
    19  type InvalidArgsLenErr int
    20  
    21  func (i InvalidArgsLenErr) Error() string {
    22  	return fmt.Sprintf("invalid number of arguments to lscc: %d", int(i))
    23  }
    24  
    25  //TXNotFoundErr transaction not found error
    26  type TXNotFoundErr string
    27  
    28  func (t TXNotFoundErr) Error() string {
    29  	return fmt.Sprintf("transaction not found: %s", string(t))
    30  }
    31  
    32  //InvalidDeploymentSpecErr invalid chaincode deployment spec error
    33  type InvalidDeploymentSpecErr string
    34  
    35  func (f InvalidDeploymentSpecErr) Error() string {
    36  	return fmt.Sprintf("invalid deployment spec: %s", string(f))
    37  }
    38  
    39  //ExistsErr chaincode exists error
    40  type ExistsErr string
    41  
    42  func (t ExistsErr) Error() string {
    43  	return fmt.Sprintf("chaincode with name '%s' already exists", string(t))
    44  }
    45  
    46  //NotFoundErr chaincode not registered with LSCC error
    47  type NotFoundErr string
    48  
    49  func (t NotFoundErr) Error() string {
    50  	return fmt.Sprintf("could not find chaincode with name '%s'", string(t))
    51  }
    52  
    53  //InvalidChannelNameErr invalid channel name error
    54  type InvalidChannelNameErr string
    55  
    56  func (f InvalidChannelNameErr) Error() string {
    57  	return fmt.Sprintf("invalid channel name: %s", string(f))
    58  }
    59  
    60  //InvalidChaincodeNameErr invalid chaincode name error
    61  type InvalidChaincodeNameErr string
    62  
    63  func (f InvalidChaincodeNameErr) Error() string {
    64  	return fmt.Sprintf("invalid chaincode name '%s'. Names must start with an alphanumeric character and can only consist of alphanumerics, '_', and '-'", string(f))
    65  }
    66  
    67  //InvalidVersionErr invalid version error
    68  type InvalidVersionErr string
    69  
    70  func (f InvalidVersionErr) Error() string {
    71  	return fmt.Sprintf("invalid chaincode version '%s'. Versions must not be empty and can only consist of alphanumerics, '_',  '-', '+', and '.'", string(f))
    72  }
    73  
    74  //InvalidStatedbArtifactsErr invalid state database artifacts error
    75  type InvalidStatedbArtifactsErr string
    76  
    77  func (f InvalidStatedbArtifactsErr) Error() string {
    78  	return fmt.Sprintf("invalid state database artifact: %s", string(f))
    79  }
    80  
    81  //ChaincodeMismatchErr chaincode name from two places don't match
    82  type ChaincodeMismatchErr string
    83  
    84  func (f ChaincodeMismatchErr) Error() string {
    85  	return fmt.Sprintf("chaincode name mismatch: %s", string(f))
    86  }
    87  
    88  //MarshallErr error marshaling/unmarshalling
    89  type MarshallErr string
    90  
    91  func (m MarshallErr) Error() string {
    92  	return fmt.Sprintf("error while marshalling: %s", string(m))
    93  }
    94  
    95  //IdenticalVersionErr trying to upgrade to same version of Chaincode
    96  type IdenticalVersionErr string
    97  
    98  func (f IdenticalVersionErr) Error() string {
    99  	return fmt.Sprintf("version already exists for chaincode with name '%s'", string(f))
   100  }
   101  
   102  //InvalidCCOnFSError error due to mismatch between fingerprint on lscc and installed CC
   103  type InvalidCCOnFSError string
   104  
   105  func (f InvalidCCOnFSError) Error() string {
   106  	return fmt.Sprintf("chaincode fingerprint mismatch: %s", string(f))
   107  }
   108  
   109  //InstantiationPolicyMissing when no existing instantiation policy is found when upgrading CC
   110  type InstantiationPolicyMissing string
   111  
   112  func (f InstantiationPolicyMissing) Error() string {
   113  	return "instantiation policy missing"
   114  }
   115  
   116  // CollectionsConfigUpgradesNotAllowed when V1_2 capability is not enabled
   117  type CollectionsConfigUpgradesNotAllowed string
   118  
   119  func (f CollectionsConfigUpgradesNotAllowed) Error() string {
   120  	return "as V1_2 capability is not enabled, collection upgrades are not allowed"
   121  }
   122  
   123  // PrivateChannelDataNotAvailable when V1_2 or later capability is not enabled
   124  type PrivateChannelDataNotAvailable string
   125  
   126  func (f PrivateChannelDataNotAvailable) Error() string {
   127  	return "as V1_2 or later capability is not enabled, private channel collections and data are not available"
   128  }