Errwrap everywhere (#4252)

* package api

* package builtin/credential

* package builtin/logical

* package command

* package helper

* package http and logical

* package physical

* package shamir

* package vault

* package vault

* address feedback

* more fixes
This commit is contained in:
Vishal Nayak
2018-04-05 11:49:21 -04:00
committed by GitHub
parent f13a832a9f
commit e2bb2ec3b9
159 changed files with 811 additions and 741 deletions

View File

@@ -9,6 +9,7 @@ import (
"os"
"strings"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/password"
@@ -252,14 +253,14 @@ func (c *OperatorGenerateRootCommand) Run(args []string) int {
// verifyOTP verifies the given OTP code is exactly 16 bytes.
func (c *OperatorGenerateRootCommand) verifyOTP(otp string) error {
if len(otp) == 0 {
return fmt.Errorf("No OTP passed in")
return fmt.Errorf("no OTP passed in")
}
otpBytes, err := base64.StdEncoding.DecodeString(otp)
if err != nil {
return fmt.Errorf("Error decoding base64 OTP value: %s", err)
return errwrap.Wrapf("error decoding base64 OTP value: {{err}}", err)
}
if otpBytes == nil || len(otpBytes) != 16 {
return fmt.Errorf("Decoded OTP value is invalid or wrong length")
return fmt.Errorf("decoded OTP value is invalid or wrong length")
}
return nil