def test_sync_task_error_handling(exporter):
    """Test error handling in synchronous task"""
    error_message = "Intentional test error"

    @task(name="failing_task")
    def failing_task():
        raise ValueError(error_message)

    with pytest.raises(ValueError, match=error_message):
        failing_task()

    spans = exporter.get_finished_spans()
    assert len(spans) == 1

    task_span = spans[0]
    assert task_span.name == "failing_task.task"
    assert task_span.status.status_code == StatusCode.ERROR
    assert error_message in task_span.status.description
Test error handling in synchronous task
packages/traceloop-sdk/tests/test_tasks.py