Skip to content

Commit 5283ca1

Browse files
committed
Make error messages from the server available
Many APIs return error codes and error messages in case of errors. Previously, only error codes have been handled which were used to construct generic protocol errors with predefined error messages. Error messages from the Kafka cluster were skipped altogether. This PR makes the error messages from the Kafka cluster available inside the protocol errors if those have been provided. This way, more detailed information about the issue can be accessed.
1 parent 4966e07 commit 5283ca1

File tree

74 files changed

+147
-136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+147
-136
lines changed

src/apis/admin/alter-client-quotas-v1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export function parseResponse (
106106
}
107107

108108
if (entry.errorCode !== 0) {
109-
errors.push([`/entries/${i}`, entry.errorCode])
109+
errors.push([`/entries/${i}`, [entry.errorCode, entry.errorMessage]])
110110
}
111111

112112
return entry

src/apis/admin/alter-configs-v2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ export function parseResponse (
7373
throttleTimeMs: reader.readInt32(),
7474
responses: reader.readArray((r, i) => {
7575
const errorCode = r.readInt16()
76+
const errorMessage = r.readNullableString()
7677

7778
if (errorCode !== 0) {
78-
errors.push([`/responses/${i}`, errorCode])
79+
errors.push([`/responses/${i}`, [errorCode, errorMessage]])
7980
}
8081

8182
return {
8283
errorCode,
83-
errorMessage: r.readNullableString(),
84+
errorMessage,
8485
resourceType: r.readInt8(),
8586
resourceName: r.readString()
8687
}

src/apis/admin/alter-partition-reassignments-v0.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@ export function parseResponse (
7676

7777
const throttleTimeMs = reader.readInt32()
7878
const errorCode = reader.readInt16()
79+
const errorMessage = reader.readNullableString()
7980

8081
if (errorCode !== 0) {
81-
errors.push(['', errorCode])
82+
errors.push(['', [errorCode, errorMessage ?? '']])
8283
}
8384

8485
const response: AlterPartitionReassignmentsResponse = {
8586
throttleTimeMs,
8687
errorCode,
87-
errorMessage: reader.readNullableString(),
88+
errorMessage,
8889
responses: reader.readArray((r, i) => {
8990
return {
9091
name: r.readString(),
@@ -96,7 +97,7 @@ export function parseResponse (
9697
}
9798

9899
if (partition.errorCode !== 0) {
99-
errors.push([`responses/${i}/partitions/${j}`, partition.errorCode])
100+
errors.push([`responses/${i}/partitions/${j}`, [partition.errorCode, partition.errorMessage]])
100101
}
101102

102103
return partition

src/apis/admin/alter-partition-v3.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function parseResponse (
104104
const errorCode = reader.readInt16()
105105

106106
if (errorCode !== 0) {
107-
errors.push(['/', errorCode])
107+
errors.push(['/', [errorCode, null]])
108108
}
109109

110110
const response: AlterPartitionResponse = {
@@ -125,7 +125,7 @@ export function parseResponse (
125125
}
126126

127127
if (partition.errorCode !== 0) {
128-
errors.push([`/topics/${i}/partitions/${j}`, partition.errorCode])
128+
errors.push([`/topics/${i}/partitions/${j}`, [partition.errorCode, null]])
129129
}
130130

131131
return partition

src/apis/admin/alter-replica-log-dirs-v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function parseResponse (
7676
}
7777

7878
if (partition.errorCode !== 0) {
79-
errors.push([`/results/${i}/partitions/${j}`, partition.errorCode])
79+
errors.push([`/results/${i}/partitions/${j}`, [partition.errorCode, null]])
8080
}
8181

8282
return partition

src/apis/admin/alter-user-scram-credentials-v0.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function parseResponse (
8787
}
8888

8989
if (result.errorCode !== 0) {
90-
errors.push([`/results/${i}`, result.errorCode])
90+
errors.push([`/results/${i}`, [result.errorCode, result.errorMessage]])
9191
}
9292

9393
return result

src/apis/admin/consumer-group-describe-v0.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@ export function parseResponse (
101101
throttleTimeMs: reader.readInt32(),
102102
groups: reader.readArray((r, i) => {
103103
const errorCode = r.readInt16()
104+
const errorMessage = r.readNullableString()
104105

105106
if (errorCode !== 0) {
106-
errors.push([`/groups/${i}`, errorCode])
107+
errors.push([`/groups/${i}`, [errorCode, errorMessage]])
107108
}
108109

109110
return {
110111
errorCode,
111-
errorMessage: r.readNullableString(),
112+
errorMessage,
112113
groupId: r.readString(),
113114
groupState: r.readString(),
114115
groupEpoch: r.readInt32(),

src/apis/admin/create-acls-v3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function parseResponse (
7575
}
7676

7777
if (result.errorCode !== 0) {
78-
errors.push([`/results/${i}`, result.errorCode])
78+
errors.push([`/results/${i}`, [result.errorCode, result.errorMessage]])
7979
}
8080

8181
return result

src/apis/admin/create-delegation-token-v3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function parseResponse (
8383
}
8484

8585
if (response.errorCode !== 0) {
86-
throw new ResponseError(apiKey, apiVersion, { '': response.errorCode }, response)
86+
throw new ResponseError(apiKey, apiVersion, { '/': [response.errorCode, null] }, response)
8787
}
8888

8989
return response

src/apis/admin/create-partitions-v3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function parseResponse (
7979
}
8080

8181
if (result.errorCode !== 0) {
82-
errors.push([`/results/${i}`, result.errorCode])
82+
errors.push([`/results/${i}`, [result.errorCode, result.errorMessage]])
8383
}
8484

8585
return result

0 commit comments

Comments
 (0)