Version: v0.0.0-...-1ee6361 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2020 License: Apache-2.0 Imports: 8 Imported by: 0



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.



This section is empty.


View Source
var CodeName = map[int32]string{
	0:  "OK",
	1:  "UNKNOWN",
	4:  "EMPTY_CERT",
	5:  "TIMEOUT",

CodeName maps the codes in this packages to human-readable strings

View Source
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


func ToFabricCommonStatusCode

func ToFabricCommonStatusCode(c int32) common.Status

ToFabricCommonStatusCode cast to common.Status

func ToGRPCStatusCode

func ToGRPCStatusCode(c int32) grpcCodes.Code

ToGRPCStatusCode cast to gRPC status code

func ToOrdererStatusCode

func ToOrdererStatusCode(c int32) common.Status

ToOrdererStatusCode cast to peer status

func ToPeerStatusCode

func ToPeerStatusCode(c int32) common.Status

ToPeerStatusCode cast to peer status

func ToTransactionValidationCode

func ToTransactionValidationCode(c int32) pb.TxValidationCode

ToTransactionValidationCode cast to transaction validation status code


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

	// PrematureChaincodeExecution indicates that an attempt was made to invoke a chaincode that's
	// in the process of being launched.
	PrematureChaincodeExecution Code = 21

	// ChaincodeAlreadyLaunching indicates that an attempt for multiple simultaneous invokes was made to launch chaincode
	ChaincodeAlreadyLaunching Code = 22

	// ChaincodeNameNotFound indicates that an that an attempt was made to invoke a chaincode that's not yet initialized
	ChaincodeNameNotFound Code = 23

func ToSDKStatusCode

func ToSDKStatusCode(c int32) Code

ToSDKStatusCode cast to fabric-sdk-go status code

func (Code) String

func (c Code) String() string

String representation of the code

func (Code) ToInt32

func (c Code) ToInt32() int32

ToInt32 cast to int32

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
	// HTTPTransportStatus is the status associated with requests made over HTTP
	// connections

	// EndorserServerStatus status returned by the endorser server
	// EventServerStatus status returned by the event service
	// OrdererServerStatus status returned by the ordering service
	// FabricCAServerStatus status returned by the Fabric CA server

	// EndorserClientStatus status returned from the endorser client
	// OrdererClientStatus status returned from the orderer client
	// ClientStatus is a generic client status

	// ChaincodeStatus defines the status codes returned by chaincode

	// DiscoveryServerStatus status returned by the Discovery Server

	// TestStatus is used by tests to create retry codes.

func (Group) String

func (g Group) String() string

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

func FromError(err error) (s *Status, ok bool)

FromError returns a Status representing err if available, otherwise it returns nil, false.

func New

func New(group Group, code int32, msg string, details []interface{}) *Status

New returns a Status with the given parameters

func NewFromExtractedChaincodeError

func NewFromExtractedChaincodeError(code int, message string) *Status

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

func (*Status) Error

func (s *Status) Error() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL