diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2017-01-15 21:50:38 +0000 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2017-01-15 22:43:41 +0000 |
commit | 17b17fc8bb690d1f6344e5af1c62b3b37166bc48 (patch) | |
tree | 8e50f8ea3f5a38002447021e7fdcacfa48c4c9cd /client/keys.go | |
parent | d3d2d5384cbb53c91c321c552cc56b42c90437fa (diff) |
Add more context to errors
Diffstat (limited to 'client/keys.go')
-rw-r--r-- | client/keys.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/client/keys.go b/client/keys.go index 3d2fb31..73983a8 100644 --- a/client/keys.go +++ b/client/keys.go @@ -8,6 +8,8 @@ import ( "crypto/rsa" "fmt" + "github.com/pkg/errors" + "golang.org/x/crypto/ed25519" "golang.org/x/crypto/ssh" ) @@ -68,7 +70,7 @@ func generateECDSAKey(size int) (Key, error) { case 521: curve = elliptic.P521() default: - return nil, fmt.Errorf("Unsupported key size: %d. Valid sizes are '256', '384', '521'", size) + return nil, fmt.Errorf("Unsupported ECDSA key size: %d. Valid sizes are '256', '384', '521'", size) } return ecdsa.GenerateKey(curve, rand.Reader) } @@ -101,8 +103,8 @@ func GenerateKey(options ...func(*options)) (Key, ssh.PublicKey, error) { privkey, err = generateRSAKey(config.size) } if err != nil { - return nil, nil, err + return nil, nil, errors.Wrapf(err, "unable to generate %s key-pair", config.keytype) } pubkey, err = ssh.NewPublicKey(privkey.Public()) - return privkey, pubkey, err + return privkey, pubkey, errors.Wrap(err, "error parsing public key") } |