Skip to content

Commit f8535d3

Browse files
committed
wrap errors with makeError
1 parent 66ec903 commit f8535d3

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

alterclientquotas.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ type AlterClientQuotaOps struct {
5050
}
5151

5252
type AlterClientQuotaResponseQuotas struct {
53-
// The error code, or `0` if the quota alteration succeeded.
54-
ErrorCode int16
55-
56-
// The error message, or `nil` if the quota alteration succeeded.
57-
ErrorMessage string
53+
// Error is set to a non-nil value including the code and message if a top-level
54+
// error was encountered when doing the update.
55+
Error error
5856

5957
// The altered quota entities.
6058
Entities []AlterClientQuotaEntity
@@ -120,9 +118,8 @@ func (c *Client) AlterClientQuotas(ctx context.Context, req *AlterClientQuotasRe
120118
}
121119

122120
responseEntries[responseEntryIdx] = AlterClientQuotaResponseQuotas{
123-
ErrorCode: responseEntry.ErrorCode,
124-
ErrorMessage: responseEntry.ErrorMessage,
125-
Entities: responseEntities,
121+
Error: makeError(responseEntry.ErrorCode, responseEntry.ErrorMessage),
122+
Entities: responseEntities,
126123
}
127124
}
128125
ret := &AlterClientQuotasResponse{

alterclientquotas_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TestClientAlterClientQuotas(t *testing.T) {
5252
Throttle: 0,
5353
Entries: []AlterClientQuotaResponseQuotas{
5454
{
55-
ErrorCode: 0,
55+
Error: makeError(0, ""),
5656
Entities: []AlterClientQuotaEntity{
5757
{
5858
EntityName: entityName,
@@ -80,8 +80,8 @@ func TestClientAlterClientQuotas(t *testing.T) {
8080
}
8181

8282
expectedDescribeResp := DescribeClientQuotasResponse{
83-
Throttle: 0,
84-
ErrorCode: 0,
83+
Throttle: 0,
84+
Error: makeError(0, ""),
8585
Entries: []DescribeClientQuotasResponseQuotas{
8686
{
8787
Entities: []DescribeClientQuotasEntity{

describeclientquotas.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ type DescribeClientQuotasResponse struct {
4040
// The amount of time that the broker throttled the request.
4141
Throttle time.Duration `kafka:"min=v0,max=v1"`
4242

43-
// The error code, or `0` if the quota description succeeded.
44-
ErrorCode int16 `kafka:"min=v0,max=v1"`
45-
46-
// The error message, or `null` if the quota description succeeded.
47-
ErrorMessage string `kafka:"min=v0,max=v1,nullable"`
43+
// Error is set to a non-nil value including the code and message if a top-level
44+
// error was encountered when doing the update.
45+
Error error
4846

4947
// List of describe client quota responses.
5048
Entries []DescribeClientQuotasResponseQuotas `kafka:"min=v0,max=v1"`

0 commit comments

Comments
 (0)