Skip to content

Commit 7a38838

Browse files
authored
Merge pull request #104 from optiopay/add_error_types
add support for new error codes
2 parents 004b9ef + f68c292 commit 7a38838

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

proto/errors.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,45 @@ var (
3838
ErrGroupAuthorizationFailed = &KafkaError{30, "group authorization failed"}
3939
ErrClusterAuthorizationFailed = &KafkaError{31, "cluster authorization failed"}
4040
ErrInvalidTimeStamp = &KafkaError{32, "timestamp of the message is out of acceptable range"}
41+
ErrUnsupportedSaslMechanism = &KafkaError{33, "The broker does not support the requested SASL mechanism."}
42+
ErrIllegalSaslState = &KafkaError{34, "Request is not valid given the current SASL state."}
43+
ErrUnsupportedVersion = &KafkaError{35, "The version of API is not supported."}
44+
ErrTopicAlreadyExists = &KafkaError{36, "Topic with this name already exists."}
45+
ErrInvalidPartitions = &KafkaError{37, "Number of partitions is invalid."}
46+
ErrInvalidReplicationFactor = &KafkaError{38, "Replication-factor is invalid."}
47+
ErrInvalidReplicaAssignment = &KafkaError{39, "Replica assignment is invalid."}
48+
ErrInvalidConfig = &KafkaError{40, "Configuration is invalid."}
49+
ErrNotController = &KafkaError{41, "This is not the correct controller for this cluster."}
50+
ErrInvalidRequest = &KafkaError{42, "This most likely occurs because of a request being malformed by the client library or the message was sent to an incompatible broker. See the broker logs for more details."}
51+
ErrUnsupportedForMessageFormat = &KafkaError{43, "The message format version on the broker does not support the request."}
52+
ErrPolicyViolation = &KafkaError{44, "Request parameters do not satisfy the configured policy."}
53+
ErrOutOfOrderSequenceNumber = &KafkaError{45, "The broker received an out of order sequence number"}
54+
ErrDuplicateSequenceNumber = &KafkaError{46, "The broker received a duplicate sequence number"}
55+
ErrInvalidProducerEpoch = &KafkaError{47, "Producer attempted an operation with an old epoch. Either there is a newer producer with the same transactionalId, or the producer's transaction has been expired by the broker."}
56+
ErrInvalidTxnState = &KafkaError{48, "The producer attempted a transactional operation in an invalid state"}
57+
ErrInvalidProducerIdMapping = &KafkaError{49, "The producer attempted to use a producer id which is not currently assigned to its transactional id"}
58+
ErrInvalidTransactionTimeout = &KafkaError{50, "The transaction timeout is larger than the maximum value allowed by the broker (as configured by transaction.max.timeout.ms)."}
59+
ErrConcurrentTransactions = &KafkaError{51, "The producer attempted to update a transaction while another concurrent operation on the same transaction was ongoing"}
60+
ErrTransactionCoordinatorFenced = &KafkaError{52, "Indicates that the transaction coordinator sending a WriteTxnMarker is no longer the current coordinator for a given producer"}
61+
ErrTransactionalIdAuthorizationFailed = &KafkaError{53, "Transactional Id authorization failed"}
62+
ErrSecurityDisabled = &KafkaError{54, "Security features are disabled."}
63+
ErrOperationNotAttempted = &KafkaError{55, "The broker did not attempt to execute this operation. This may happen for batched RPCs where some operations in the batch failed, causing the broker to respond without trying the rest."}
64+
ErrKafkaStorageError = &KafkaError{56, "Disk error when trying to access log file on the disk."}
65+
ErrLogDirNotFound = &KafkaError{57, "The user-specified log directory is not found in the broker config."}
66+
ErrSaslAuthenticationFailed = &KafkaError{58, "SASL Authentication failed."}
67+
ErrUnknownProducerId = &KafkaError{59, "This exception is raised by the broker if it could not locate the producer metadata associated with the producerId in question. This could happen if, for instance, the producer's records were deleted because their retention time had elapsed. Once the last records of the producerId are removed, the producer's metadata is removed from the broker, and future appends by the producer will return this exception."}
68+
ErrReassignmentInProgress = &KafkaError{60, "A partition reassignment is in progress"}
69+
ErrDelegationTokenAuthDisabled = &KafkaError{61, "Delegation Token feature is not enabled."}
70+
ErrDelegationTokenNotFound = &KafkaError{62, "Delegation Token is not found on server."}
71+
ErrDelegationTokenOwnerMismatch = &KafkaError{63, "Specified Principal is not valid Owner/Renewer."}
72+
ErrDelegationTokenRequestNotAllowed = &KafkaError{64, "Delegation Token requests are not allowed on PLAINTEXT/1-way SSL channels and on delegation token authenticated channels."}
73+
ErrDelegationTokenAuthorizationFailed = &KafkaError{65, "Delegation Token authorization failed."}
74+
ErrDelegationTokenExpired = &KafkaError{66, "Delegation Token is expired."}
75+
ErrInvalidPrincipalType = &KafkaError{67, "Supplied principalType is not supported"}
76+
ErrNonEmptyGroup = &KafkaError{68, "The group The group is not empty is not empty"}
77+
ErrGroupIdNotFound = &KafkaError{69, "The group id The group id does not exist was not found"}
78+
ErrFetchSessionIdNotFound = &KafkaError{70, "The fetch session ID was not found"}
79+
ErrInvalidFetchSessionEpoch = &KafkaError{71, "The fetch session epoch is invalid"}
4180

4281
errnoToErr = map[int16]error{
4382
-1: ErrUnknown,
@@ -73,6 +112,45 @@ var (
73112
30: ErrGroupAuthorizationFailed,
74113
31: ErrClusterAuthorizationFailed,
75114
32: ErrInvalidCommitOffsetSize,
115+
33: ErrUnsupportedSaslMechanism,
116+
34: ErrIllegalSaslState,
117+
35: ErrUnsupportedVersion,
118+
36: ErrTopicAlreadyExists,
119+
37: ErrInvalidPartitions,
120+
38: ErrInvalidReplicationFactor,
121+
39: ErrInvalidReplicaAssignment,
122+
40: ErrInvalidConfig,
123+
41: ErrNotController,
124+
42: ErrInvalidRequest,
125+
43: ErrUnsupportedForMessageFormat,
126+
44: ErrPolicyViolation,
127+
45: ErrOutOfOrderSequenceNumber,
128+
46: ErrDuplicateSequenceNumber,
129+
47: ErrInvalidProducerEpoch,
130+
48: ErrInvalidTxnState,
131+
49: ErrInvalidProducerIdMapping,
132+
50: ErrInvalidTransactionTimeout,
133+
51: ErrConcurrentTransactions,
134+
52: ErrTransactionCoordinatorFenced,
135+
53: ErrTransactionalIdAuthorizationFailed,
136+
54: ErrSecurityDisabled,
137+
55: ErrOperationNotAttempted,
138+
56: ErrKafkaStorageError,
139+
57: ErrLogDirNotFound,
140+
58: ErrSaslAuthenticationFailed,
141+
59: ErrUnknownProducerId,
142+
60: ErrReassignmentInProgress,
143+
61: ErrDelegationTokenAuthDisabled,
144+
62: ErrDelegationTokenNotFound,
145+
63: ErrDelegationTokenOwnerMismatch,
146+
64: ErrDelegationTokenRequestNotAllowed,
147+
65: ErrDelegationTokenAuthorizationFailed,
148+
66: ErrDelegationTokenExpired,
149+
67: ErrInvalidPrincipalType,
150+
68: ErrNonEmptyGroup,
151+
69: ErrGroupIdNotFound,
152+
70: ErrFetchSessionIdNotFound,
153+
71: ErrInvalidFetchSessionEpoch,
76154
}
77155
)
78156

proto/messages.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,7 @@ type TopicError struct {
24802480
Topic string
24812481
ErrorCode int16
24822482
ErrorMessage string // >= KafkaV1
2483+
Err error
24832484
}
24842485

24852486
type CreateTopicsResp struct {
@@ -2552,6 +2553,7 @@ func ReadVersionedCreateTopicsResp(r io.Reader, version int16) (*CreateTopicsRes
25522553
if resp.Version >= KafkaV1 {
25532554
te.ErrorMessage = dec.DecodeString()
25542555
}
2556+
te.Err = errFromNo(te.ErrorCode)
25552557
}
25562558

25572559
if dec.Err() != nil {

proto/messages_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ func TestVersionedCreateTopicResponse(t *testing.T) {
11751175
TopicError{
11761176
ErrorCode: 1,
11771177
Topic: "mytopic",
1178+
Err: ErrOffsetOutOfRange,
11781179
},
11791180
},
11801181
}

0 commit comments

Comments
 (0)