Skip to content

Commit

Permalink
lib: improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonTian committed Jan 4, 2024
1 parent 516e575 commit d87e7c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions config/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -45,7 +45,7 @@ func MigrateCredentials(path string) (conf *Configuration, err error) {
conf = &Configuration{}
ini, err := ini.Load(path)
if err != nil {
err = fmt.Errorf(" parse failed: %v\n", err)
err = fmt.Errorf(" parse failed: %v", err)
return
}

Expand Down Expand Up @@ -81,7 +81,7 @@ func MigrateCredentials(path string) (conf *Configuration, err error) {
func MigrateConfigure(path string, conf *Configuration) (err error) {
ini, err := ini.Load(path)
if err != nil {
err = fmt.Errorf("parse failed: %s\n", err)
err = fmt.Errorf("parse failed: %s", err)
return
}

Expand Down
6 changes: 3 additions & 3 deletions config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (cp *Profile) GetClientByCredentialsURI(config *sdk.Config, ctx *cli.Contex
}

if res.StatusCode != 200 {
return nil, fmt.Errorf("Get Credentials from %s failed, status code %d", uri, res.StatusCode)
return nil, fmt.Errorf("get credentials from %s failed, status code %d", uri, res.StatusCode)
}

body, err := io.ReadAll(res.Body)
Expand All @@ -441,11 +441,11 @@ func (cp *Profile) GetClientByCredentialsURI(config *sdk.Config, ctx *cli.Contex
var response Response
err = json.Unmarshal(body, &response)
if err != nil {
return nil, fmt.Errorf("Unmarshal credentials failed, the body %s", string(body))
return nil, fmt.Errorf("unmarshal credentials failed, the body %s", string(body))
}

if response.Code != "Success" {
return nil, fmt.Errorf("Get sts token err, Code is not Success")
return nil, fmt.Errorf("get sts token err, Code is not Success")
}

cred := credentials.NewStsTokenCredential(response.AccessKeyId, response.AccessKeySecret, response.SecurityToken)
Expand Down

0 comments on commit d87e7c8

Please sign in to comment.