Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Add error handling for action execution in service.py
Magnus Müller84d7504c5e86
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.pyindex a6dccd187..4a9d390da 100644--- a/browser_use/controller/service.py+++ b/browser_use/controller/service.py@@ -1038,18 +1038,22 @@ Explain the content of the page and that the requested information is not availaspan_context = nullcontext()with span_context:- result = await self.registry.execute_action(- action_name=action_name,- params=params,- browser_session=browser_session,- page_extraction_llm=page_extraction_llm,- file_system=file_system,- sensitive_data=sensitive_data,- available_file_paths=available_file_paths,- context=context,- )+ try:+ result = await self.registry.execute_action(+ action_name=action_name,+ params=params,+ browser_session=browser_session,+ page_extraction_llm=page_extraction_llm,+ file_system=file_system,+ sensitive_data=sensitive_data,+ available_file_paths=available_file_paths,+ context=context,+ )+ except Exception as e:+ result = ActionResult(error=str(e))- # Laminar.set_span_output(result)+ if Laminar is not None:+ Laminar.set_span_output(result)if isinstance(result, str):return ActionResult(extracted_content=result)