SDK error revamp (#432)
SDK methods now return 1 error. To differentiate between Client errors and Server errors I've also implemented the AsServerError function which returns an *api.Error if it is an error originating from the remote server or nil otherwise.
This commit is contained in:
1 parent
94f9d952be
commit
fd0da998e8
53 files changed
+1512
-1635
No files matched your search
@@ -20,7 +20,6 @@ import (
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping"
|
||||
"github.com/hashicorp/vault/sdk/helper/base62"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/kr/pretty"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -119,7 +118,7 @@ func (tc *TestController) Token() *authtokens.AuthToken {
|
||||
tc.t.Error("no default auth method ID configured")
|
||||
return nil
|
||||
}
|
||||
token, apiErr, err := authmethods.NewClient(tc.Client()).Authenticate(
|
||||
token, err := authmethods.NewClient(tc.Client()).Authenticate(
|
||||
tc.Context(),
|
||||
tc.b.DevAuthMethodId,
|
||||
map[string]interface{}{
|
||||
@@ -131,10 +130,6 @@ func (tc *TestController) Token() *authtokens.AuthToken {
|
||||
tc.t.Error(fmt.Errorf("error logging in: %w", err))
|
||||
return nil
|
||||
}
|
||||
if apiErr != nil {
|
||||
tc.t.Error(fmt.Errorf("api err from logging in: %s", pretty.Sprint(apiErr)))
|
||||
return nil
|
||||
}
|
||||
return token.Item
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user