@@ -20,8 +20,14 @@ async def __call__(self, *args, **kwargs):
2020from anthropic .types .message import Message
2121from anthropic .types .message_delta_event import MessageDeltaEvent
2222from anthropic .types .message_start_event import MessageStartEvent
23- from anthropic .types import ErrorResponse , OverloadedError
24- from anthropic import APIStatusError
23+
24+ try :
25+ from anthropic .types import ErrorResponse , OverloadedError
26+ from anthropic import APIStatusError
27+ except ImportError :
28+ ErrorResponse = None
29+ OverloadedError = None
30+ APIStatusError = None
2531
2632try :
2733 from anthropic .types import InputJSONDelta
@@ -534,6 +540,10 @@ def test_streaming_create_message_iterator_methods(
534540 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_ID ] == "msg_01XFDUDYJgAACzvnptvVoYEL"
535541
536542
543+ @pytest .mark .skipif (
544+ ANTHROPIC_VERSION < (0 , 41 ),
545+ reason = "Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954." ,
546+ )
537547def test_streaming_create_message_api_error (
538548 sentry_init ,
539549 capture_events ,
@@ -954,6 +964,10 @@ def test_stream_messages_iterator_methods(
954964 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_ID ] == "msg_01XFDUDYJgAACzvnptvVoYEL"
955965
956966
967+ @pytest .mark .skipif (
968+ ANTHROPIC_VERSION < (0 , 41 ),
969+ reason = "Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954." ,
970+ )
957971def test_stream_messages_api_error (
958972 sentry_init ,
959973 capture_events ,
@@ -1385,6 +1399,10 @@ async def test_streaming_create_message_async_iterator_methods(
13851399 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_ID ] == "msg_01XFDUDYJgAACzvnptvVoYEL"
13861400
13871401
1402+ @pytest .mark .skipif (
1403+ ANTHROPIC_VERSION < (0 , 41 ),
1404+ reason = "Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954." ,
1405+ )
13881406@pytest .mark .asyncio
13891407async def test_streaming_create_message_async_api_error (
13901408 sentry_init ,
@@ -1712,6 +1730,10 @@ async def test_stream_messages_async_next_consumption(
17121730 assert span ["data" ][SPANDATA .GEN_AI_RESPONSE_ID ] == "msg_01XFDUDYJgAACzvnptvVoYEL"
17131731
17141732
1733+ @pytest .mark .skipif (
1734+ ANTHROPIC_VERSION < (0 , 41 ),
1735+ reason = "Error classes moved in https://github.com/anthropics/anthropic-sdk-python/commit/4e0b15e22fe40e9aa513459564f641bf97c90954." ,
1736+ )
17151737@pytest .mark .asyncio
17161738async def test_stream_messages_async_api_error (
17171739 sentry_init ,
0 commit comments