Skip to content

Commit 50106e9

Browse files
committed
Return http status of errors in client.
1 parent de82a77 commit 50106e9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

internal/client/graph_client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (gc *GraphClient) ReadCurrentGraph() (*knowledge.Graph, error) {
5555
if res.StatusCode == http.StatusUnauthorized {
5656
return nil, fmt.Errorf("Unauthorized access. Check your auth token")
5757
} else if res.StatusCode != http.StatusOK {
58-
return nil, fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
58+
return nil, fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
5959
}
6060

6161
b, err := ioutil.ReadAll(res.Body)
@@ -98,7 +98,7 @@ func (gc *GraphClient) UpdateSchema(sg schema.SchemaGraph) error {
9898
} else if res.StatusCode == http.StatusTooManyRequests {
9999
return ErrTooManyRequests
100100
} else if res.StatusCode != http.StatusOK {
101-
return fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
101+
return fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
102102
}
103103
return nil
104104
}
@@ -130,7 +130,7 @@ func (gc *GraphClient) UpsertAsset(asset knowledge.Asset) error {
130130
} else if res.StatusCode == http.StatusTooManyRequests {
131131
return ErrTooManyRequests
132132
} else if res.StatusCode != http.StatusOK {
133-
return fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
133+
return fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
134134
}
135135
return nil
136136
}
@@ -162,7 +162,7 @@ func (gc *GraphClient) DeleteAsset(asset knowledge.Asset) error {
162162
} else if res.StatusCode == http.StatusTooManyRequests {
163163
return ErrTooManyRequests
164164
} else if res.StatusCode != http.StatusOK {
165-
return fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
165+
return fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
166166
}
167167
return nil
168168
}
@@ -194,7 +194,7 @@ func (gc *GraphClient) UpsertRelation(relation knowledge.Relation) error {
194194
} else if res.StatusCode == http.StatusTooManyRequests {
195195
return ErrTooManyRequests
196196
} else if res.StatusCode != http.StatusOK {
197-
return fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
197+
return fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
198198
}
199199
return nil
200200
}
@@ -226,7 +226,7 @@ func (gc *GraphClient) DeleteRelation(relation knowledge.Relation) error {
226226
} else if res.StatusCode == http.StatusTooManyRequests {
227227
return ErrTooManyRequests
228228
} else if res.StatusCode != http.StatusOK {
229-
return fmt.Errorf("Expected status code 200 and got %d", res.StatusCode)
229+
return fmt.Errorf("Expected status code 200 and got %d: %s", res.StatusCode, res.Status)
230230
}
231231
return nil
232232
}

0 commit comments

Comments
 (0)