@@ -142,9 +142,9 @@ async def test_protocol_error_during_query(self, mock_session):
142
142
What this tests:
143
143
---------------
144
144
1. Protocol errors during execution
145
- 2. ProtocolError wrapped in QueryError
146
- 3. Original exception preserved
147
- 4. Error details maintained
145
+ 2. ProtocolError passed through without wrapping
146
+ 3. Direct exception access
147
+ 4. Error details preserved as-is
148
148
149
149
Why this matters:
150
150
----------------
@@ -153,8 +153,8 @@ async def test_protocol_error_during_query(self, mock_session):
153
153
- Protocol violations
154
154
- Driver/server bugs
155
155
156
- These are serious errors requiring
157
- investigation, not just retry .
156
+ Users need direct access for
157
+ proper error handling and debugging .
158
158
"""
159
159
async_session = AsyncCassandraSession (mock_session )
160
160
@@ -163,12 +163,11 @@ async def test_protocol_error_during_query(self, mock_session):
163
163
ProtocolError ("Invalid or unsupported protocol version" )
164
164
)
165
165
166
- # ProtocolError is wrapped in QueryError
167
- with pytest .raises (QueryError ) as exc_info :
166
+ # ProtocolError is now passed through without wrapping
167
+ with pytest .raises (ProtocolError ) as exc_info :
168
168
await async_session .execute ("SELECT * FROM test" )
169
169
170
170
assert "Invalid or unsupported protocol version" in str (exc_info .value )
171
- assert isinstance (exc_info .value .__cause__ , ProtocolError )
172
171
173
172
@pytest .mark .asyncio
174
173
async def test_custom_payload_handling (self , mock_session ):
@@ -262,10 +261,10 @@ async def test_unsupported_operation(self, mock_session):
262
261
263
262
What this tests:
264
263
---------------
265
- 1. UnsupportedOperation errors handled
266
- 2. Wrapped in QueryError
267
- 3. Feature limitations clear
268
- 4. Version-specific features
264
+ 1. UnsupportedOperation errors passed through
265
+ 2. No wrapping - direct exception access
266
+ 3. Feature limitations clearly visible
267
+ 4. Version-specific features preserved
269
268
270
269
Why this matters:
271
270
----------------
@@ -274,8 +273,8 @@ async def test_unsupported_operation(self, mock_session):
274
273
- Duration type (v5+)
275
274
- Per-query keyspace (v5+)
276
275
277
- Clear errors help users understand
278
- feature availability .
276
+ Users need direct access to handle
277
+ version-specific feature errors .
279
278
"""
280
279
async_session = AsyncCassandraSession (mock_session )
281
280
@@ -284,12 +283,11 @@ async def test_unsupported_operation(self, mock_session):
284
283
UnsupportedOperation ("Continuous paging is not supported by this protocol version" )
285
284
)
286
285
287
- # UnsupportedOperation is wrapped in QueryError
288
- with pytest .raises (QueryError ) as exc_info :
286
+ # UnsupportedOperation is now passed through without wrapping
287
+ with pytest .raises (UnsupportedOperation ) as exc_info :
289
288
await async_session .execute ("SELECT * FROM test" )
290
289
291
290
assert "Continuous paging is not supported" in str (exc_info .value )
292
- assert isinstance (exc_info .value .__cause__ , UnsupportedOperation )
293
291
294
292
@pytest .mark .asyncio
295
293
async def test_protocol_error_recovery (self , mock_session ):
@@ -414,10 +412,9 @@ async def test_timeout_vs_protocol_error(self, mock_session):
414
412
ProtocolError ("Protocol violation" )
415
413
)
416
414
417
- # ProtocolError is wrapped in QueryError
418
- with pytest .raises (QueryError ) as exc_info :
415
+ # ProtocolError is now passed through without wrapping
416
+ with pytest .raises (ProtocolError ) :
419
417
await async_session .execute ("SELECT * FROM test" )
420
- assert isinstance (exc_info .value .__cause__ , ProtocolError )
421
418
422
419
@pytest .mark .asyncio
423
420
async def test_prepare_with_protocol_error (self , mock_session ):
@@ -427,9 +424,9 @@ async def test_prepare_with_protocol_error(self, mock_session):
427
424
What this tests:
428
425
---------------
429
426
1. Prepare can fail with protocol error
430
- 2. Wrapped in QueryError
431
- 3. Statement preparation issues
432
- 4. Error details preserved
427
+ 2. Passed through without wrapping
428
+ 3. Statement preparation issues visible
429
+ 4. Direct exception access
433
430
434
431
Why this matters:
435
432
----------------
@@ -438,20 +435,19 @@ async def test_prepare_with_protocol_error(self, mock_session):
438
435
- Protocol limitations
439
436
- Query complexity problems
440
437
441
- Clear errors help debug
442
- statement preparation issues .
438
+ Users need direct access to
439
+ handle preparation failures .
443
440
"""
444
441
async_session = AsyncCassandraSession (mock_session )
445
442
446
443
# Prepare fails with protocol error
447
444
mock_session .prepare .side_effect = ProtocolError ("Cannot prepare statement" )
448
445
449
- # Should be wrapped in QueryError
450
- with pytest .raises (QueryError ) as exc_info :
446
+ # ProtocolError is now passed through without wrapping
447
+ with pytest .raises (ProtocolError ) as exc_info :
451
448
await async_session .prepare ("SELECT * FROM test WHERE id = ?" )
452
449
453
450
assert "Cannot prepare statement" in str (exc_info .value )
454
- assert isinstance (exc_info .value .__cause__ , ProtocolError )
455
451
456
452
@pytest .mark .asyncio
457
453
async def test_execution_profile_with_protocol_settings (self , mock_session ):
@@ -499,9 +495,9 @@ async def test_batch_with_protocol_error(self, mock_session):
499
495
What this tests:
500
496
---------------
501
497
1. Batch operations can hit protocol limits
502
- 2. Protocol errors wrapped appropriately
503
- 3. Batch size limits enforced
504
- 4. Clear error messaging
498
+ 2. Protocol errors passed through directly
499
+ 3. Batch size limits visible to users
500
+ 4. Native exception handling
505
501
506
502
Why this matters:
507
503
----------------
@@ -510,8 +506,8 @@ async def test_batch_with_protocol_error(self, mock_session):
510
506
- Statement count limits
511
507
- Protocol buffer constraints
512
508
513
- Large batches must be split
514
- to avoid protocol errors.
509
+ Users need direct access to
510
+ handle batch size errors.
515
511
"""
516
512
from cassandra .query import BatchStatement , BatchType
517
513
@@ -527,12 +523,11 @@ async def test_batch_with_protocol_error(self, mock_session):
527
523
ProtocolError ("Batch too large for protocol" )
528
524
)
529
525
530
- # Should be wrapped in QueryError
531
- with pytest .raises (QueryError ) as exc_info :
526
+ # ProtocolError is now passed through without wrapping
527
+ with pytest .raises (ProtocolError ) as exc_info :
532
528
await async_session .execute_batch (batch )
533
529
534
530
assert "Batch too large" in str (exc_info .value )
535
- assert isinstance (exc_info .value .__cause__ , ProtocolError )
536
531
537
532
@pytest .mark .asyncio
538
533
async def test_no_host_available_with_protocol_errors (self , mock_session ):
0 commit comments