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

package multi

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

Package multi is an error type that holds multiple errors. These errors typically originate from operations that target multiple nodes. For example, a transaction proposal with two endorsers could return a multi error type if both endorsers return errors


errs := Errors{}
errs = append(errs, fmt.Errorf("peer0 failed"))
errs = append(errs, fmt.Errorf("peer1 failed"))

// Multi errors implement the standard error interface and are returned as regular errors
err := interface{}(errs).(error)

// We can extract multi errors from a standard error
errs, ok := err.(Errors)

// And handle each error individually
for _, e := range errs {


peer0 failed
peer1 failed



Package Files


func Append Uses

func Append(errs error, err error) error

Append error to Errors. If the first arg is not an Errors object, one will be created

func New Uses

func New(errs ...error) error

New Errors object with the given errors. Only non-nil errors are added.

type Errors Uses

type Errors []error

Errors is used to represent multiple errors

func (Errors) Error Uses

func (errs Errors) Error() string

Error implements the error interface to return a string representation of Errors

func (Errors) ToError Uses

func (errs Errors) ToError() error

ToError converts Errors to the error interface returns nil if no errors are present, a single error object if only one is present

Package multi imports 2 packages (graph) and is imported by 10 packages. Updated 2020-02-20. Refresh now. Tools for package owners.