Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
feat: update Data Integirty error handling (#3628)
Browse files Browse the repository at this point in the history
Signed-off-by: Mykhailo Sizov <mykhailo.sizov@securekey.com>
  • Loading branch information
mishasizov-SK committed Aug 31, 2023
1 parent 9846998 commit 717faac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions component/models/dataintegrity/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (s *Signer) AddProof(doc []byte, opts *models.ProofOptions) ([]byte, error)

proof, err := signerSuite.CreateProof(doc, opts)
if err != nil {
return nil, ErrProofGeneration
// TODO update linter to use go 1.20: https://github.com/hyperledger/aries-framework-go/issues/3613
return nil, errors.Join(ErrProofGeneration, err) // nolint:typecheck
}

if proof.Type == "" || proof.ProofPurpose == "" || proof.VerificationMethod == "" {
Expand All @@ -108,7 +109,8 @@ func (s *Signer) AddProof(doc []byte, opts *models.ProofOptions) ([]byte, error)

out, err := sjson.SetRawBytes(doc, proofPath, proofRaw)
if err != nil {
return nil, ErrProofGeneration
// TODO update linter to use go 1.20: https://github.com/hyperledger/aries-framework-go/issues/3613
return nil, errors.Join(ErrProofGeneration, err) // nolint:typecheck
}

return out, nil
Expand Down
3 changes: 2 additions & 1 deletion component/models/dataintegrity/suite/ecdsa2019/ecdsa2019.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ func hashData(transformedDoc, confData []byte, h hash.Hash) []byte {

func proofConfig(docCtx interface{}, opts *models.ProofOptions) (map[string]interface{}, error) {
if opts.Purpose != opts.VerificationRelationship {
return nil, errors.New("verification method is not suitable for purpose")
return nil, fmt.Errorf(
"verification method %s is not suitable for purpose %s", opts.VerificationRelationship, opts.Purpose)
}

timeStr := opts.Created.Format(models.DateTimeFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func TestSharedFailures(t *testing.T) {
tc := successCase(t)

tc.proofOpts.Purpose = fooBar
tc.errStr = "verification method is not suitable for purpose"
tc.errStr = "verification method assertionMethod is not suitable for purpose foo bar"

testSign(t, tc)
})
Expand Down

0 comments on commit 717faac

Please sign in to comment.