Improve error handling, fix linter (#92)
* Improve error handling, fix linter
This commit is contained in:
parent
6b2ac0b11c
commit
53a85837e0
23 changed files with 194 additions and 186 deletions
|
|
@ -186,7 +186,11 @@ func (key *Key) Serialize() ([]byte, error) {
|
|||
err = key.entity.SerializePrivateWithoutSigning(&buffer, nil)
|
||||
}
|
||||
|
||||
return buffer.Bytes(), err
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "gopenpgp: error in serializing key")
|
||||
}
|
||||
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
// Armor returns the armored key as a string with default gopenpgp headers.
|
||||
|
|
@ -235,7 +239,7 @@ func (key *Key) GetArmoredPublicKeyWithCustomHeaders(comment, version string) (s
|
|||
func (key *Key) GetPublicKey() (b []byte, err error) {
|
||||
var outBuf bytes.Buffer
|
||||
if err = key.entity.Serialize(&outBuf); err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "gopenpgp: error in serializing public key")
|
||||
}
|
||||
|
||||
return outBuf.Bytes(), nil
|
||||
|
|
@ -397,7 +401,7 @@ func (key *Key) readFrom(r io.Reader, armored bool) error {
|
|||
entities, err = openpgp.ReadKeyRing(r)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "gopenpgp: error in reading key ring")
|
||||
}
|
||||
|
||||
if len(entities) > 1 {
|
||||
|
|
@ -456,7 +460,7 @@ func generateKey(
|
|||
|
||||
newEntity, err := openpgp.NewEntity(name, comments, email, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "gopengpp: error in encoding new entity")
|
||||
}
|
||||
|
||||
if newEntity.PrivateKey == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue