fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/pkg/common/errors/status Index | Examples | Files

package status

import "github.com/hyperledger/fabric-sdk-go/pkg/common/errors/status"

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.


// 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)


Client Status
proposal responses do not match



Package Files

codes.go status.go


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

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

func ToFabricCommonStatusCode Uses

func ToFabricCommonStatusCode(c int32) common.Status

ToFabricCommonStatusCode cast to common.Status

func ToGRPCStatusCode Uses

func ToGRPCStatusCode(c int32) grpcCodes.Code

ToGRPCStatusCode cast to gRPC status code

func ToOrdererStatusCode Uses

func ToOrdererStatusCode(c int32) common.Status

ToOrdererStatusCode cast to peer status

func ToPeerStatusCode Uses

func ToPeerStatusCode(c int32) common.Status

ToPeerStatusCode cast to peer status

func ToTransactionValidationCode Uses

func ToTransactionValidationCode(c int32) pb.TxValidationCode

ToTransactionValidationCode cast to transaction validation status code

type Code Uses

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

func ToSDKStatusCode Uses

func ToSDKStatusCode(c int32) Code

ToSDKStatusCode cast to fabric-sdk-go status code

func (Code) String Uses

func (c Code) String() string

String representation of the code

func (Code) ToInt32 Uses

func (c Code) ToInt32() int32

ToInt32 cast to int32

type Group Uses

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 Uses

func (g Group) String() string

type Status Uses

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 Uses

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

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

func New Uses

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

New returns a Status with the given parameters

func NewFromExtractedChaincodeError Uses

func NewFromExtractedChaincodeError(code int, message string) *Status

NewFromExtractedChaincodeError returns Status when a chaincode error occurs

func NewFromGRPCStatus Uses

func NewFromGRPCStatus(s *grpcstatus.Status) *Status

NewFromGRPCStatus new Status from gRPC status response

func NewFromProposalResponse Uses

func NewFromProposalResponse(res *pb.ProposalResponse, endorser string) *Status

NewFromProposalResponse creates a status created from the given ProposalResponse

func (*Status) Error Uses

func (s *Status) Error() string

Package status imports 8 packages (graph) and is imported by 16 packages. Updated 2020-07-03. Refresh now. Tools for package owners.