status

package
v1.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

View Source
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",
	10: "CHAINCODE_ERROR",
	21: "NO_MATCHING_CERTIFICATE_AUTHORITY_ENTITY",
	22: "NO_MATCHING_PEER_ENTITY",
	23: "NO_MATCHING_ORDERER_ENTITY",
}

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",
}

GroupName maps the groups in this packages to human-readable strings

Functions

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

Types

type ChaincodeStatus

type ChaincodeStatus struct {
	Code    int
	Message string
}

ChaincodeStatus is for extracting Code and message from chaincode GRPC errors

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 endoresement is missing
	MissingEndorsement Code = 9

	// ChaincodeError is for errors returned by Chaincode
	ChaincodeError Code = 10

	// NoMatchingCertificateAuthorityEntity is if entityMatchers are unable to find any matchingCertificateAuthority
	NoMatchingCertificateAuthorityEntity Code = 21

	// NoMatchingPeerEntity is if entityMatchers are unable to find any matchingPeer
	NoMatchingPeerEntity Code = 22

	// NoMatchingOrdererEntity is if entityMatchers are unable to find any matchingOrderer
	NoMatchingOrdererEntity 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
	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 eventhub
	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
)

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 an error occurs in GRPC Transport

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

Jump to

Keyboard shortcuts

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