Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #392 from bstasyszyn/visitorerr
Browse files Browse the repository at this point in the history
feat: Add Cause to visitorError
  • Loading branch information
bstasyszyn authored Apr 21, 2020
2 parents 817e574 + 90b0fa9 commit 934bc09
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module github.com/trustbloc/fabric-peer-ext
require (
github.com/bluele/gcache v0.0.0-20190301044115-79ae3b2d8680
github.com/btcsuite/btcutil v0.0.0-20170419141449-a5ecb5d9547a
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/golang/protobuf v1.3.2
github.com/hyperledger/fabric v2.0.0+incompatible
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200128192331-2d899240a7ed
Expand Down
4 changes: 4 additions & 0 deletions pkg/common/blockvisitor/blockvisitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,10 @@ func (e visitorError) Error() string {
return e.cause.Error()
}

func (e visitorError) Cause() error {
return e.cause
}

// haltOnError returns true if the error was handled by an error handler
// and processing should halt because of the error
func haltOnError(err error) bool {
Expand Down
7 changes: 7 additions & 0 deletions pkg/common/blockvisitor/blockvisitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,10 @@ func mockBlockWithTransactions(t *testing.T) *cb.Block {

return b.Build()
}

func TestVisitorError_Cause(t *testing.T) {
cause := errors.New("cause of the error")
err := newVisitorError(cause)
require.NotNil(t, err)
require.Equal(t, cause, errors.Cause(err))
}

0 comments on commit 934bc09

Please sign in to comment.