Skip to content

Commit

Permalink
Wrapping errors, some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xBlaz3kx committed Dec 13, 2024
1 parent f8e9ae1 commit 832718b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (p *Parser) GetPayload() (*PayloadSection, error) {
// Validate the payload if automatic validation is enabled
if p.opts.withAutomaticValidation {
if err := p.payload.Validate(); err != nil {
return nil, err
return nil, errors.Wrap(err, "payload validation failed")
}
}

Expand Down Expand Up @@ -102,17 +102,17 @@ func parseOcmfMessageFromString(data string) (*PayloadSection, *Signature, error
return nil, nil, ErrInvalidFormat
}

payloadSection := &PayloadSection{}
err := json.Unmarshal([]byte(splitData[0]), payloadSection)
payloadSection := PayloadSection{}
err := json.Unmarshal([]byte(splitData[0]), &payloadSection)
if err != nil {
return nil, nil, err
return nil, nil, errors.Wrap(err, "failed to unmarshal payload")
}

signature := &Signature{}
err = json.Unmarshal([]byte(splitData[1]), signature)
signature := Signature{}
err = json.Unmarshal([]byte(splitData[1]), &signature)
if err != nil {
return nil, nil, err
return nil, nil, errors.Wrap(err, "failed to unmarshal signature")
}

return payloadSection, signature, nil
return &payloadSection, &signature, nil
}

0 comments on commit 832718b

Please sign in to comment.