Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nexus3/mail_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (s *MailConfigService) Get() (*schema.MailConfig, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not get mail config: HTTP %d, %s", resp.StatusCode, string(body))
}
var mailconfig schema.MailConfig
if err := json.Unmarshal(body, &mailconfig); err != nil {
Expand All @@ -51,7 +51,7 @@ func (s *MailConfigService) Create(mailconfig *schema.MailConfig) error {
}

if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not create mail config: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -69,7 +69,7 @@ func (s *MailConfigService) Update(mailconfig *schema.MailConfig) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not update mail config: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -82,7 +82,7 @@ func (s *MailConfigService) Delete() error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete mail config: HTTP %d, %s", resp.StatusCode, string(body))
}
return err
}
2 changes: 1 addition & 1 deletion nexus3/pkg/security/privilege/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s SecurityPrivilegeService) Delete(name string) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete privilege '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
return err
}
8 changes: 4 additions & 4 deletions nexus3/pkg/security/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *SecurityRoleService) Create(role security.Role) error {
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not create role: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -62,7 +62,7 @@ func (s *SecurityRoleService) Get(id string) (*security.Role, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not get role '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}

var role security.Role
Expand All @@ -87,7 +87,7 @@ func (s *SecurityRoleService) Update(id string, role security.Role) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not update role '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}

return nil
Expand All @@ -102,7 +102,7 @@ func (s *SecurityRoleService) Delete(id string) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete role '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}

return nil
Expand Down
10 changes: 5 additions & 5 deletions nexus3/pkg/security/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *SecurityUserService) Create(user security.User) error {
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not create user: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -72,7 +72,7 @@ func (s *SecurityUserService) Get(id string, source *string) (*security.User, er
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not get user '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}

users, err := jsonUnmarshalUsers(body)
Expand Down Expand Up @@ -106,7 +106,7 @@ func (s *SecurityUserService) Update(id string, user security.User) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not update user '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}

return nil
Expand All @@ -119,7 +119,7 @@ func (s *SecurityUserService) Delete(id string) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete user '%s': HTTP %d, %s", id, resp.StatusCode, string(body))
}
return err
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func (s *SecurityUserService) List(source *string) ([]security.User, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not list users: HTTP %d, %s", resp.StatusCode, string(body))
}

users, err := jsonUnmarshalUsers(body)
Expand Down
10 changes: 5 additions & 5 deletions nexus3/routing_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *RoutingRuleService) Lists() ([]schema.RoutingRule, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not list routing rules: HTTP %d, %s", resp.StatusCode, string(body))
}

var rules []schema.RoutingRule
Expand All @@ -47,7 +47,7 @@ func (s *RoutingRuleService) Get(name string) (*schema.RoutingRule, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not get routing rule '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
var rule schema.RoutingRule
if err := json.Unmarshal(body, &rule); err != nil {
Expand All @@ -70,7 +70,7 @@ func (s *RoutingRuleService) Create(rule *schema.RoutingRule) error {
}

if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not create routing rule: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -88,7 +88,7 @@ func (s *RoutingRuleService) Update(rule *schema.RoutingRule) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not update routing rule '%s': HTTP %d, %s", rule.Name, resp.StatusCode, string(body))
}

return nil
Expand All @@ -101,7 +101,7 @@ func (s *RoutingRuleService) Delete(name string) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete routing rule '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
return err
}
14 changes: 7 additions & 7 deletions nexus3/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *ScriptService) List() ([]schema.Script, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not list scripts: HTTP %d, %s", resp.StatusCode, string(body))
}

var scripts []schema.Script
Expand All @@ -49,7 +49,7 @@ func (s *ScriptService) Get(name string) (*schema.Script, error) {
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s", string(body))
return nil, fmt.Errorf("could not get script '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
var script schema.Script
if err := json.Unmarshal(body, &script); err != nil {
Expand All @@ -69,7 +69,7 @@ func (s *ScriptService) Create(script *schema.Script) error {
}

if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not create script: HTTP %d, %s", resp.StatusCode, string(body))
}

return nil
Expand All @@ -87,7 +87,7 @@ func (s *ScriptService) Update(script *schema.Script) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not update script '%s': HTTP %d, %s", script.Name, resp.StatusCode, string(body))
}

return nil
Expand All @@ -100,7 +100,7 @@ func (s *ScriptService) Delete(name string) error {
}

if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not delete script '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
return err
}
Expand All @@ -112,7 +112,7 @@ func (s *ScriptService) Run(name string) error {
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not run script '%s': HTTP %d, %s", name, resp.StatusCode, string(body))
}
return err
}
Expand All @@ -124,7 +124,7 @@ func (s *ScriptService) RunWithPayload(name, payload string) error {
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("%s", string(body))
return fmt.Errorf("could not run script '%s' with payload: HTTP %d, %s", name, resp.StatusCode, string(body))
}
return err
}