Documentation ¶
Overview ¶
Package status defines metadata for errors returned by fabric-sdk-go. This information may be used by SDK users to make decisions about how to handle certain error conditions. Status codes are divided by group, where each group represents a particular component and the codes correspond to those returned by the component. These are defined in detail below.
Example ¶
// Status errors are returned for certain transient errors by clients in the SDK statusError := New(ClientStatus, EndorsementMismatch.ToInt32(), "proposal responses do not match", nil) // Status errors implement the standard error interface and are returned as regular errors err := interface{}(statusError).(error) // A user can extract status information from a status status, ok := FromError(err) fmt.Println(ok) fmt.Println(status.Group) fmt.Println(Code(status.Code)) fmt.Println(status.Message)
Output: true Client Status ENDORSEMENT_MISMATCH proposal responses do not match
Index ¶
- Variables
- func ToFabricCommonStatusCode(c int32) common.Status
- func ToGRPCStatusCode(c int32) grpcCodes.Code
- func ToOrdererStatusCode(c int32) common.Status
- func ToPeerStatusCode(c int32) common.Status
- func ToTransactionValidationCode(c int32) pb.TxValidationCode
- type Code
- type Group
- type Status
- func FromError(err error) (s *Status, ok bool)
- func New(group Group, code int32, msg string, details []interface{}) *Status
- func NewFromExtractedChaincodeError(code int, message string) *Status
- func NewFromGRPCStatus(s *grpcstatus.Status) *Status
- func NewFromProposalResponse(res *pb.ProposalResponse, endorser string) *Status
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CodeName = map[int32]string{
0: "OK",
1: "UNKNOWN",
2: "CONNECTION_FAILED",
3: "ENDORSEMENT_MISMATCH",
4: "EMPTY_CERT",
5: "TIMEOUT",
6: "NO_PEERS_FOUND",
7: "MULTIPLE_ERRORS",
8: "SIGNATURE_VERIFICATION_FAILED",
9: "MISSING_ENDORSEMENT",
11: "QUERY_ENDORSERS",
12: "GENERIC_TRANSIENT",
23: "CHAINCODE_NAME_NOT_FOUND",
24: "PRIVATE_DATA_DISSEMINATION_FAILED",
}
CodeName maps the codes in this packages to human-readable strings
var GroupName = map[int32]string{
0: "Unknown",
1: "gRPC Transport Status",
2: "HTTP Transport Status",
3: "Endorser Server Status",
4: "Event Server Status",
5: "Orderer Server Status",
6: "Fabric CA Server Status",
7: "Endorser Client Status",
8: "Orderer Client Status",
9: "Client Status",
10: "Chaincode status",
11: "Discovery status",
12: "Test status",
}
GroupName maps the groups in this packages to human-readable strings
Functions ¶
func ToFabricCommonStatusCode ¶
ToFabricCommonStatusCode cast to common.Status
func ToGRPCStatusCode ¶
ToGRPCStatusCode cast to gRPC status code
func ToOrdererStatusCode ¶
ToOrdererStatusCode cast to peer status
func ToPeerStatusCode ¶
ToPeerStatusCode cast to peer status
func ToTransactionValidationCode ¶
func ToTransactionValidationCode(c int32) pb.TxValidationCode
ToTransactionValidationCode cast to transaction validation status code
Types ¶
type Code ¶
type Code uint32
Code represents a status code
const ( // OK is returned on success. OK Code = 0 // Unknown represents status codes that are uncategorized or unknown to the SDK Unknown Code = 1 // ConnectionFailed is returned when a network connection attempt from the SDK fails ConnectionFailed Code = 2 // EndorsementMismatch is returned when there is a mismatch in endorsements received by the SDK EndorsementMismatch Code = 3 // EmptyCert is return when an empty cert is returned EmptyCert Code = 4 // Timeout operation timed out Timeout Code = 5 // NoPeersFound No peers were discovered/configured NoPeersFound Code = 6 // MultipleErrors multiple errors occurred MultipleErrors Code = 7 // SignatureVerificationFailed is when signature fails verification SignatureVerificationFailed Code = 8 // MissingEndorsement is if an endorsement is missing MissingEndorsement Code = 9 // QueryEndorsers error indicates that no endorser group was found that would // satisfy the chaincode policy QueryEndorsers Code = 11 // GenericTransient is generally used by tests to indicate that a retry is possible GenericTransient Code = 12 // ChaincodeNameNotFound indicates that an that an attempt was made to invoke a chaincode that's not yet initialized ChaincodeNameNotFound Code = 23 // PvtDataDisseminationFailed indicates that Gossip failed to disseminate private data to the required number of peers PvtDataDisseminationFailed Code = 24 )
func ToSDKStatusCode ¶
ToSDKStatusCode cast to fabric-sdk-go status code
type Group ¶
type Group int32
Group of status to help users infer status codes from various components
const ( // UnknownStatus unknown status group UnknownStatus Group = iota // GRPCTransportStatus is the status associated with requests made over // gRPC connections GRPCTransportStatus // HTTPTransportStatus is the status associated with requests made over HTTP // connections HTTPTransportStatus // EndorserServerStatus status returned by the endorser server EndorserServerStatus // EventServerStatus status returned by the event service EventServerStatus // OrdererServerStatus status returned by the ordering service OrdererServerStatus // FabricCAServerStatus status returned by the Fabric CA server FabricCAServerStatus // EndorserClientStatus status returned from the endorser client EndorserClientStatus // OrdererClientStatus status returned from the orderer client OrdererClientStatus // ClientStatus is a generic client status ClientStatus // ChaincodeStatus defines the status codes returned by chaincode ChaincodeStatus // DiscoveryServerStatus status returned by the Discovery Server DiscoveryServerStatus // TestStatus is used by tests to create retry codes. TestStatus )
type Status ¶
type Status struct { // Group status group Group Group // Code status code Code int32 // Message status message Message string // Details any additional status details Details []interface{} }
Status provides additional information about an unsuccessful operation performed by fabric-sdk-go. Essentially, this object contains metadata about an error returned by the SDK.
func FromError ¶
FromError returns a Status representing err if available, otherwise it returns nil, false.
func NewFromExtractedChaincodeError ¶
NewFromExtractedChaincodeError returns Status when a chaincode error occurs
func NewFromGRPCStatus ¶
func NewFromGRPCStatus(s *grpcstatus.Status) *Status
NewFromGRPCStatus new Status from gRPC status response
func NewFromProposalResponse ¶
func NewFromProposalResponse(res *pb.ProposalResponse, endorser string) *Status
NewFromProposalResponse creates a status created from the given ProposalResponse