@@ -3623,14 +3623,18 @@ def _llm_type(self) -> str:
36233623 if span_streaming or stream_gen_ai_spans :
36243624 items = capture_items ("event" )
36253625
3626- with start_transaction (), pytest .raises (ValueError ):
3626+ with start_transaction (), pytest .raises (
3627+ ValueError , match = "API rate limit error"
3628+ ):
36273629 list (agent_executor .stream ({"input" : "How many letters in the word eudca" }))
36283630
36293631 (error ,) = (item .payload for item in items )
36303632 else :
36313633 events = capture_events ()
36323634
3633- with start_transaction (), pytest .raises (ValueError ):
3635+ with start_transaction (), pytest .raises (
3636+ ValueError , match = "API rate limit error"
3637+ ):
36343638 list (agent_executor .stream ({"input" : "How many letters in the word eudca" }))
36353639
36363640 error = events [0 ]
@@ -3698,7 +3702,7 @@ def _llm_type(self) -> str:
36983702 agent = agent , tools = [get_word_length ], verbose = True
36993703 )
37003704
3701- with pytest .raises (ValueError ):
3705+ with pytest .raises (ValueError , match = "API rate limit error" ):
37023706 list (
37033707 agent_executor .stream (
37043708 {"input" : "How many letters in the word eudca" }
@@ -3737,7 +3741,7 @@ def _llm_type(self) -> str:
37373741 agent = agent , tools = [get_word_length ], verbose = True
37383742 )
37393743
3740- with pytest .raises (ValueError ):
3744+ with pytest .raises (ValueError , match = "API rate limit error" ):
37413745 list (
37423746 agent_executor .stream (
37433747 {"input" : "How many letters in the word eudca" }
@@ -3777,7 +3781,7 @@ def _llm_type(self) -> str:
37773781 agent = agent , tools = [get_word_length ], verbose = True
37783782 )
37793783
3780- with pytest .raises (ValueError ):
3784+ with pytest .raises (ValueError , match = "API rate limit error" ):
37813785 list (
37823786 agent_executor .stream (
37833787 {"input" : "How many letters in the word eudca" }
@@ -3857,7 +3861,9 @@ def test_langchain_tool_error(
38573861
38583862 with patch .object (
38593863 llm .client ._client ._client , "send" , side_effect = [tool_response ]
3860- ), start_transaction (name = "tx" ), pytest .raises (ValueError ):
3864+ ), start_transaction (name = "tx" ), pytest .raises (
3865+ ValueError , match = "Tool execution failed"
3866+ ):
38613867 agent .invoke ({"messages" : [HumanMessage (content = "hi" )]})
38623868
38633869 error_events = [event for event in events if event .get ("level" ) == "error" ]
0 commit comments