Skip to content

Commit

Permalink
Minor renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudhartert-db committed Jul 2, 2024
1 parent cb875e1 commit 079a0e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions apierr/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@ func parseErrorFromResponse(resp *http.Response, requestBody, responseBody []byt

// Anonymous struct used to unmarshal JSON Databricks API error responses.
var errorBody struct {
ErrorCode any `json:"error_code,omitempty"` // int or string
Message string `json:"message,omitempty"`
Details []ErrorDetail `json:"details,omitempty"`

API12Error string `json:"error,omitempty"`
ErrorCode any `json:"error_code,omitempty"` // int or string
Message string `json:"message,omitempty"`
Details []ErrorDetail `json:"details,omitempty"`
API12Error string `json:"error,omitempty"`

// The following fields are for scim api only. See RFC7644 section 3.7.3
// https://tools.ietf.org/html/rfc7644#section-3.7.3
Expand Down Expand Up @@ -209,7 +208,7 @@ func unknownAPIError(resp *http.Response, requestBody, responseBody []byte, err
StatusCode: resp.StatusCode,
}

// This is most likely HTML... since un-marshalling JSON failed
// this is most likely HTML... since un-marshalling JSON failed
// Status parts first in case html message is not as expected
statusParts := strings.SplitN(resp.Status, " ", 2)
if len(statusParts) < 2 {
Expand Down
10 changes: 5 additions & 5 deletions apierr/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGetAPIError_HandlesEmptyResponse(t *testing.T) {
func TestGetAPIError_handlesEmptyResponse(t *testing.T) {
resp := common.ResponseWrapper{
Response: &http.Response{
Request: &http.Request{
Expand All @@ -32,7 +32,7 @@ func TestGetAPIError_HandlesEmptyResponse(t *testing.T) {
assert.Equal(t, err.(*APIError).Message, "")
}

func TestGetAPIError_AppliesOverrides(t *testing.T) {
func TestGetAPIError_appliesOverrides(t *testing.T) {
resp := common.ResponseWrapper{
Response: &http.Response{
StatusCode: http.StatusBadRequest,
Expand All @@ -52,7 +52,7 @@ func TestGetAPIError_AppliesOverrides(t *testing.T) {
assert.ErrorIs(t, err, ErrResourceDoesNotExist)
}

func TestGetAPIError_ParseIntErrorCode(t *testing.T) {
func TestGetAPIError_parseIntErrorCode(t *testing.T) {
resp := common.ResponseWrapper{
Response: &http.Response{
StatusCode: http.StatusBadRequest,
Expand All @@ -73,7 +73,7 @@ func TestGetAPIError_ParseIntErrorCode(t *testing.T) {
assert.Equal(t, err.(*APIError).ErrorCode, "500")
}

func TestGetAPIError_MapsPrivateLinkRedirect(t *testing.T) {
func TestGetAPIError_mapsPrivateLinkRedirect(t *testing.T) {
resp := common.ResponseWrapper{
Response: &http.Response{
Request: &http.Request{
Expand All @@ -92,7 +92,7 @@ func TestGetAPIError_MapsPrivateLinkRedirect(t *testing.T) {
assert.Equal(t, err.(*APIError).ErrorCode, "PRIVATE_LINK_VALIDATION_ERROR")
}

func TestAPIError_TransientRegexMatches(t *testing.T) {
func TestAPIError_transientRegexMatches(t *testing.T) {
err := APIError{
Message: "worker env WorkerEnvId(workerenv-XXXXX) not found",
}
Expand Down

0 comments on commit 079a0e4

Please sign in to comment.