Home / Function/ test_exception_error_message() — langchain Function Reference

test_exception_error_message() — langchain Function Reference

Architecture documentation for the test_exception_error_message() function in test_model_call_limit.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  0fb22524_e400_c3e0_2310_0a88fbae2ddc["test_exception_error_message()"]
  43d91b2d_3fa0_6f03_b3b8_f87c64a4f30a["test_model_call_limit.py"]
  0fb22524_e400_c3e0_2310_0a88fbae2ddc -->|defined in| 43d91b2d_3fa0_6f03_b3b8_f87c64a4f30a
  style 0fb22524_e400_c3e0_2310_0a88fbae2ddc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_call_limit.py lines 171–201

def test_exception_error_message() -> None:
    """Test that the exception provides clear error messages."""
    middleware = ModelCallLimitMiddleware(thread_limit=2, run_limit=1, exit_behavior="error")

    # Test thread limit exceeded
    state = ModelCallLimitState(messages=[], thread_model_call_count=2, run_model_call_count=0)
    with pytest.raises(ModelCallLimitExceededError) as exc_info:
        middleware.before_model(state, Runtime())

    error_msg = str(exc_info.value)
    assert "Model call limits exceeded" in error_msg
    assert "thread limit (2/2)" in error_msg

    # Test run limit exceeded
    state = ModelCallLimitState(messages=[], thread_model_call_count=0, run_model_call_count=1)
    with pytest.raises(ModelCallLimitExceededError) as exc_info:
        middleware.before_model(state, Runtime())

    error_msg = str(exc_info.value)
    assert "Model call limits exceeded" in error_msg
    assert "run limit (1/1)" in error_msg

    # Test both limits exceeded
    state = ModelCallLimitState(messages=[], thread_model_call_count=2, run_model_call_count=1)
    with pytest.raises(ModelCallLimitExceededError) as exc_info:
        middleware.before_model(state, Runtime())

    error_msg = str(exc_info.value)
    assert "Model call limits exceeded" in error_msg
    assert "thread limit (2/2)" in error_msg
    assert "run limit (1/1)" in error_msg

Domain

Subdomains

Frequently Asked Questions

What does test_exception_error_message() do?
test_exception_error_message() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_call_limit.py.
Where is test_exception_error_message() defined?
test_exception_error_message() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_model_call_limit.py at line 171.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free