@@ -422,7 +422,7 @@ public void StoreOffset(ConsumeResult<TKey, TValue> result)
422
422
/// `enable.auto.offset.store` must be set to "false" when using this API.
423
423
/// </remarks>
424
424
/// <param name="offset">
425
- /// The offset to be commited .
425
+ /// The offset to be committed .
426
426
/// </param>
427
427
/// <exception cref="Confluent.Kafka.KafkaException">
428
428
/// Thrown if the request failed.
@@ -1014,7 +1014,7 @@ private ConsumeResult<K, V> ConsumeImpl<K,V>(
1014
1014
new SerializationContext ( MessageComponentType . Key , topic ) ) ;
1015
1015
}
1016
1016
}
1017
- catch ( Exception exception )
1017
+ catch ( Exception ex )
1018
1018
{
1019
1019
throw new ConsumeException (
1020
1020
new ConsumeResult < byte [ ] , byte [ ] >
@@ -1030,7 +1030,7 @@ private ConsumeResult<K, V> ConsumeImpl<K,V>(
1030
1030
IsPartitionEOF = false
1031
1031
} ,
1032
1032
new Error ( ErrorCode . Local_KeyDeserialization ) ,
1033
- exception ) ;
1033
+ ex ) ;
1034
1034
}
1035
1035
1036
1036
V val ;
@@ -1046,7 +1046,7 @@ private ConsumeResult<K, V> ConsumeImpl<K,V>(
1046
1046
new SerializationContext ( MessageComponentType . Value , topic ) ) ;
1047
1047
}
1048
1048
}
1049
- catch ( Exception exception )
1049
+ catch ( Exception ex )
1050
1050
{
1051
1051
throw new ConsumeException (
1052
1052
new ConsumeResult < byte [ ] , byte [ ] >
@@ -1062,7 +1062,7 @@ private ConsumeResult<K, V> ConsumeImpl<K,V>(
1062
1062
IsPartitionEOF = false
1063
1063
} ,
1064
1064
new Error ( ErrorCode . Local_ValueDeserialization ) ,
1065
- exception ) ;
1065
+ ex ) ;
1066
1066
}
1067
1067
1068
1068
return new ConsumeResult < K , V >
@@ -1100,19 +1100,35 @@ private ConsumeResult<TKey, TValue> ConsumeViaBytes(int millisecondsTimeout)
1100
1100
} ;
1101
1101
}
1102
1102
1103
- TKey key = keyDeserializer != null
1104
- ? keyDeserializer . Deserialize ( rawResult . Key , rawResult . Key == null , new SerializationContext ( MessageComponentType . Key , rawResult . Topic ) )
1105
- : Task . Run ( async ( ) => await asyncKeyDeserializer . DeserializeAsync ( new ReadOnlyMemory < byte > ( rawResult . Key ) , rawResult . Key == null , new SerializationContext ( MessageComponentType . Key , rawResult . Topic ) ) )
1106
- . ConfigureAwait ( continueOnCapturedContext : false )
1107
- . GetAwaiter ( )
1108
- . GetResult ( ) ;
1103
+ TKey key ;
1104
+ try
1105
+ {
1106
+ key = keyDeserializer != null
1107
+ ? keyDeserializer . Deserialize ( rawResult . Key , rawResult . Key == null , new SerializationContext ( MessageComponentType . Key , rawResult . Topic ) )
1108
+ : Task . Run ( async ( ) => await asyncKeyDeserializer . DeserializeAsync ( new ReadOnlyMemory < byte > ( rawResult . Key ) , rawResult . Key == null , new SerializationContext ( MessageComponentType . Key , rawResult . Topic ) ) )
1109
+ . ConfigureAwait ( continueOnCapturedContext : false )
1110
+ . GetAwaiter ( )
1111
+ . GetResult ( ) ;
1112
+ }
1113
+ catch ( Exception ex )
1114
+ {
1115
+ throw new ConsumeException ( rawResult , new Error ( ErrorCode . Local_KeyDeserialization ) , ex ) ;
1116
+ }
1109
1117
1110
- TValue val = valueDeserializer != null
1111
- ? valueDeserializer . Deserialize ( rawResult . Value , rawResult . Value == null , new SerializationContext ( MessageComponentType . Value , rawResult . Topic ) )
1112
- : Task . Run ( async ( ) => await asyncValueDeserializer . DeserializeAsync ( new ReadOnlyMemory < byte > ( rawResult . Value ) , rawResult == null , new SerializationContext ( MessageComponentType . Value , rawResult . Topic ) ) )
1113
- . ConfigureAwait ( continueOnCapturedContext : false )
1114
- . GetAwaiter ( )
1115
- . GetResult ( ) ;
1118
+ TValue val ;
1119
+ try
1120
+ {
1121
+ val = valueDeserializer != null
1122
+ ? valueDeserializer . Deserialize ( rawResult . Value , rawResult . Value == null , new SerializationContext ( MessageComponentType . Value , rawResult . Topic ) )
1123
+ : Task . Run ( async ( ) => await asyncValueDeserializer . DeserializeAsync ( new ReadOnlyMemory < byte > ( rawResult . Value ) , rawResult == null , new SerializationContext ( MessageComponentType . Value , rawResult . Topic ) ) )
1124
+ . ConfigureAwait ( continueOnCapturedContext : false )
1125
+ . GetAwaiter ( )
1126
+ . GetResult ( ) ;
1127
+ }
1128
+ catch ( Exception ex )
1129
+ {
1130
+ throw new ConsumeException ( rawResult , new Error ( ErrorCode . Local_ValueDeserialization ) , ex ) ;
1131
+ }
1116
1132
1117
1133
return new ConsumeResult < TKey , TValue >
1118
1134
{
@@ -1140,10 +1156,18 @@ private ConsumeResult<TKey, TValue> ConsumeViaBytes(int millisecondsTimeout)
1140
1156
/// The consume result.
1141
1157
/// </returns>
1142
1158
/// <remarks>
1143
- /// OnPartitionsAssigned/Revoked and OnOffsetsCommitted events may
1159
+ /// The partitions assigned/revoked and offsets committed handlers may
1144
1160
/// be invoked as a side-effect of calling this method (on the same
1145
1161
/// thread).
1146
1162
/// </remarks>
1163
+ /// <exception cref="ConsumeException">
1164
+ /// Thrown when a call to this method is unsuccessful for any reason
1165
+ /// (except cancellation by user). Inspect the Error property of the
1166
+ /// exception for detailed information.
1167
+ /// </exception>
1168
+ /// <exception cref="OperationCanceledException">
1169
+ /// Thrown on cancellation.
1170
+ /// </exception>
1147
1171
public ConsumeResult < TKey , TValue > Consume ( CancellationToken cancellationToken = default ( CancellationToken ) )
1148
1172
{
1149
1173
while ( true )
@@ -1172,10 +1196,14 @@ private ConsumeResult<TKey, TValue> ConsumeViaBytes(int millisecondsTimeout)
1172
1196
/// The consume result.
1173
1197
/// </returns>
1174
1198
/// <remarks>
1175
- /// OnPartitionsAssigned/Revoked and OnOffsetsCommitted events may
1199
+ /// The partitions assigned/revoked and offsets committed handlers may
1176
1200
/// be invoked as a side-effect of calling this method (on the same
1177
1201
/// thread).
1178
1202
/// </remarks>
1203
+ /// <exception cref="ConsumeException">
1204
+ /// Thrown when a call to this method is unsuccessful for any reason.
1205
+ /// Inspect the Error property of the exception for detailed information.
1206
+ /// </exception>
1179
1207
public ConsumeResult < TKey , TValue > Consume ( TimeSpan timeout )
1180
1208
=> ( keyDeserializer != null && valueDeserializer != null )
1181
1209
? ConsumeImpl < TKey , TValue > ( timeout . TotalMillisecondsAsInt ( ) , keyDeserializer , valueDeserializer ) // fast path for simple case
0 commit comments