Skip to content

Commit

Permalink
refactor APIError
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Theel committed Feb 20, 2020
1 parent fa5c63b commit 33b1a7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func CreatePolicy(t *testing.T, client GoCloak, clientID string, policy PolicyRe
clientID,
policy)
assert.NoError(t, err, "CreatePolicy failed")

t.Logf("Created Policy ID: %s ", *(createdPolicy.ID))

tearDown := func() {
Expand Down
9 changes: 5 additions & 4 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gocloak

import (
"encoding/json"
"strconv"
"strings"
)

Expand Down Expand Up @@ -54,15 +55,15 @@ func (s *StringOrArray) MarshalJSON() ([]byte, error) {
return json.Marshal([]string(*s))
}

// APIError represents an api error
// APIError holds message and statusCode for api errors
type APIError struct {
Code int
Message string
Code int `json:"code"`
Message string `json:"message"`
}

// Error stringifies the APIError
func (apiError APIError) Error() string {
return apiError.Message
return "Code: " + strconv.Itoa(apiError.Code) + " Message: " + apiError.Message
}

// CertResponseKey is returned by the certs endpoint
Expand Down

0 comments on commit 33b1a7a

Please sign in to comment.