@@ -142,9 +142,9 @@ async def test_protocol_error_during_query(self, mock_session):
142142 What this tests:
143143 ---------------
144144 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
148148
149149 Why this matters:
150150 ----------------
@@ -153,8 +153,8 @@ async def test_protocol_error_during_query(self, mock_session):
153153 - Protocol violations
154154 - Driver/server bugs
155155
156- These are serious errors requiring
157- investigation, not just retry .
156+ Users need direct access for
157+ proper error handling and debugging .
158158 """
159159 async_session = AsyncCassandraSession (mock_session )
160160
@@ -163,12 +163,11 @@ async def test_protocol_error_during_query(self, mock_session):
163163 ProtocolError ("Invalid or unsupported protocol version" )
164164 )
165165
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 :
168168 await async_session .execute ("SELECT * FROM test" )
169169
170170 assert "Invalid or unsupported protocol version" in str (exc_info .value )
171- assert isinstance (exc_info .value .__cause__ , ProtocolError )
172171
173172 @pytest .mark .asyncio
174173 async def test_custom_payload_handling (self , mock_session ):
@@ -262,10 +261,10 @@ async def test_unsupported_operation(self, mock_session):
262261
263262 What this tests:
264263 ---------------
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
269268
270269 Why this matters:
271270 ----------------
@@ -274,8 +273,8 @@ async def test_unsupported_operation(self, mock_session):
274273 - Duration type (v5+)
275274 - Per-query keyspace (v5+)
276275
277- Clear errors help users understand
278- feature availability .
276+ Users need direct access to handle
277+ version-specific feature errors .
279278 """
280279 async_session = AsyncCassandraSession (mock_session )
281280
@@ -284,12 +283,11 @@ async def test_unsupported_operation(self, mock_session):
284283 UnsupportedOperation ("Continuous paging is not supported by this protocol version" )
285284 )
286285
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 :
289288 await async_session .execute ("SELECT * FROM test" )
290289
291290 assert "Continuous paging is not supported" in str (exc_info .value )
292- assert isinstance (exc_info .value .__cause__ , UnsupportedOperation )
293291
294292 @pytest .mark .asyncio
295293 async def test_protocol_error_recovery (self , mock_session ):
@@ -414,10 +412,9 @@ async def test_timeout_vs_protocol_error(self, mock_session):
414412 ProtocolError ("Protocol violation" )
415413 )
416414
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 ) :
419417 await async_session .execute ("SELECT * FROM test" )
420- assert isinstance (exc_info .value .__cause__ , ProtocolError )
421418
422419 @pytest .mark .asyncio
423420 async def test_prepare_with_protocol_error (self , mock_session ):
@@ -427,9 +424,9 @@ async def test_prepare_with_protocol_error(self, mock_session):
427424 What this tests:
428425 ---------------
429426 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
433430
434431 Why this matters:
435432 ----------------
@@ -438,20 +435,19 @@ async def test_prepare_with_protocol_error(self, mock_session):
438435 - Protocol limitations
439436 - Query complexity problems
440437
441- Clear errors help debug
442- statement preparation issues .
438+ Users need direct access to
439+ handle preparation failures .
443440 """
444441 async_session = AsyncCassandraSession (mock_session )
445442
446443 # Prepare fails with protocol error
447444 mock_session .prepare .side_effect = ProtocolError ("Cannot prepare statement" )
448445
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 :
451448 await async_session .prepare ("SELECT * FROM test WHERE id = ?" )
452449
453450 assert "Cannot prepare statement" in str (exc_info .value )
454- assert isinstance (exc_info .value .__cause__ , ProtocolError )
455451
456452 @pytest .mark .asyncio
457453 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):
499495 What this tests:
500496 ---------------
501497 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
505501
506502 Why this matters:
507503 ----------------
@@ -510,8 +506,8 @@ async def test_batch_with_protocol_error(self, mock_session):
510506 - Statement count limits
511507 - Protocol buffer constraints
512508
513- Large batches must be split
514- to avoid protocol errors.
509+ Users need direct access to
510+ handle batch size errors.
515511 """
516512 from cassandra .query import BatchStatement , BatchType
517513
@@ -527,12 +523,11 @@ async def test_batch_with_protocol_error(self, mock_session):
527523 ProtocolError ("Batch too large for protocol" )
528524 )
529525
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 :
532528 await async_session .execute_batch (batch )
533529
534530 assert "Batch too large" in str (exc_info .value )
535- assert isinstance (exc_info .value .__cause__ , ProtocolError )
536531
537532 @pytest .mark .asyncio
538533 async def test_no_host_available_with_protocol_errors (self , mock_session ):
0 commit comments